/*
 * Copyright (C) 2019 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

module.exports = {
  presets: [
    [
      '@instructure/ui-babel-preset',
      {
        esModules:
          'USE_ES_MODULES' in process.env
            ? process.env.USE_ES_MODULES !== 'false'
            : !process.env.JEST_WORKER_ID,
        node: !!process.env.JEST_WORKER_ID,
        transformImports: false
      }
    ]
  ],
  plugins: ['@babel/plugin-proposal-optional-chaining'],
  env: {
    production: {
      plugins: [
        'transform-react-remove-prop-types',
        '@babel/plugin-transform-react-inline-elements'
      ]
    }
  }
}

@@ -697,119 +697,31 @@
 */%0A%0A
-module.exports = %7B%0A  presets: %5B%0A    %5B%0A      '@instructure/ui-babel-preset',%0A      %7B%0A        esModules:%0A        
+const USE_ES_MODULES =%0A
   'U
@@ -750,24 +750,16 @@
 ess.env%0A
-        
     ? pr
@@ -795,24 +795,16 @@
 'false'%0A
-        
     : !p
@@ -828,26 +828,145 @@
 ORKER_ID
+%0A%0Amodule.exports = %7B%0A  presets: %5B%0A    %5B%0A      '@instructure/ui-babel-preset',%0A      %7B%0A        esModules: USE_ES_MODULES
 ,%0A
- 
        
+ 
 node: !!
@@ -995,41 +995,8 @@
 R_ID
-,%0A        transformImports: false
 %0A   
@@ -1233,8 +1233,736 @@
 %7D%0A  %7D%0A%7D%0A
+%0A// we can't just use the transformImports option of @instructure/ui-babel-preset because%0A// @instructure/ui-media-player uses the old pattern of putting things in /components like InstUI used to do%0Aif (!USE_ES_MODULES) %7B%0A  module.exports.plugins = %5B%0A    %5B%0A      '@instructure/babel-plugin-transform-imports',%0A      %7B%0A        '(@instructure/ui-%5B%5E/%5D+)$': %7B%0A          transform: (importName, matches) =%3E %7B%0A            if (%0A              !matches %7C%7C%0A              !matches%5B1%5D %7C%7C%0A              matches%5B1%5D === '@instructure/ui-test-utils' %7C%7C%0A              matches%5B1%5D.startsWith('@instructure/ui-media')%0A            )%0A              return%0A            return %60$%7Bmatches%5B1%5D%7D/lib/$%7BimportName%7D%60%0A          %7D%0A        %7D%0A      %7D%0A    %5D%0A  %5D%0A%7D%0A

Transform instUI imports so jest loads less code