Skip to content
Snippets Groups Projects
Select Git revision
  • 7e6ea40ab18c99b2018233628cedc63d74f5963d
  • mui5-annotation-on-video-stable default
  • get_setter_canvasSizeInformations
  • fix-error-div-into-p
  • annotation-on-video-v2
  • detached
  • annotation-on-video-r17
  • mui5
  • mui5-react-18
  • jacob-test
  • annotation-on-video protected
  • master
  • test-antoinev1
  • 20-fetch-thumbnail-on-annotation
  • add-research-field
  • Save
  • add-plugin
  • 14-wip-no-seek-to
  • 14-bug-on-video-time-control
  • 9_wip_videotests
  • _upgrade_material_ui
  • latest-tetras-16
  • v3.3.0
  • v3.2.0
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v3.0.0-rc.7
  • v3.0.0-rc.6
  • v3.0.0-rc.5
  • v3.0.0-rc.4
  • v3.0.0-rc.3
  • v3.0.0-rc.2
  • v3.0.0-rc.1
  • v3.0.0-beta.10
  • v3.0.0-beta.9
  • v3.0.0-beta.8
  • v3.0.0-beta.7
  • v3.0.0-beta.6
  • v3.0.0-beta.5
  • v3.0.0-beta.3
41 results

babel.config.js

Blame
  • user avatar
    Jack Reed authored and Chris Beer committed
    efcc5f3d
    History
    babel.config.js 1.85 KiB
    /*
     * babel.config.js used to support a UMD built version of Mirador that is
     * compatible with IE11 and Edge.
     */
    
    const moduleFormatMap = {
      cjs: 'commonjs',
      es: false,
    };
    
    // eslint-disable-next-line func-names
    module.exports = function (api) {
      const isDevelopmentEnv = api.env('development');
      const isProductionEnv = api.env('production');
      const isTestEnv = api.env('test');
    
      const presets = [
        isTestEnv && [
          '@babel/preset-env',
          {
            modules: 'commonjs',
            targets: {
              node: 'current',
            },
          },
          '@babel/preset-react',
        ],
        (isProductionEnv || isDevelopmentEnv) && [
          '@babel/preset-env',
          {
            corejs: 3,
            exclude: ['transform-typeof-symbol'],
            forceAllTransforms: true,
            modules: moduleFormatMap[process.env.MODULE_FORMAT] || false,
            useBuiltIns: 'entry',
          },
        ],
        [
          '@babel/preset-react',
          {
            development: isDevelopmentEnv || isTestEnv,
            useBuiltIns: true,
          },
        ],
      ].filter(Boolean);
    
      const plugins = [
        'babel-plugin-macros',
        '@babel/plugin-transform-destructuring',
        [
          '@babel/plugin-proposal-class-properties',
          {
            loose: true,
          },
        ],
        [
          '@babel/plugin-proposal-object-rest-spread',
          {
            useBuiltIns: true,
          },
        ],
        [
          '@babel/plugin-transform-runtime',
          {
            corejs: false,
            helpers: false, // Needed to support IE/Edge
            regenerator: true,
          },
        ],
        [
          '@babel/plugin-transform-regenerator',
          {
            async: false,
          },
        ],
        ['transform-react-remove-prop-types',
          {
            ignoreFilenames: ['node_modules'],
            removeImport: true,
          },
        ],
        ['lodash', {
          id: [
            'lodash',
          ],
        },
        ],
      ].filter(Boolean);
    
      return {
        plugins,
        presets,
      };
    };