Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// eslint-disable-next-line import/no-extraneous-dependencies
const version = require('@babel/helpers/package.json').version
babelHelperVersion.version = version
} catch (e) {
// if something goes wrong, continue and don't try to explicitly set a helper version
}
plugins = plugins.concat([
require('babel-plugin-macros'),
require('@babel/plugin-transform-destructuring').default,
[require('@babel/plugin-proposal-decorators').default, { legacy: true }], // must run before themeable-styles plugin below
[require('@babel/plugin-proposal-class-properties').default, { loose: true }],
require('@babel/plugin-proposal-export-default-from').default,
[require('@babel/plugin-proposal-object-rest-spread').default, { useBuiltIns: true }],
require('@babel/plugin-proposal-optional-chaining').default,
[require('@babel/plugin-transform-runtime').default, {
...babelHelperVersion,
corejs: false,
regenerator: true,
helpers: true,
useESModules: opts.esModules
}],
require('@babel/plugin-syntax-dynamic-import').default,
require('babel-plugin-transform-undefined-to-void')
])
if (process.env.NODE_ENV === 'production') {
plugins.push(
require('@babel/plugin-transform-react-constant-elements').default
)
}
'useEffect',
'useContext',
'useReducer',
'useCallback',
'useMemo',
'useRef',
'useImperativeHandle',
'useLayoutEffect',
'useDebugValue',
],
},
],
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
require('@babel/plugin-transform-runtime').default,
{
corejs: false,
helpers: areHelpersEnabled,
regenerator: true,
// https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
// We should turn this on once the lowest version of Node LTS
// supports ES Modules.
useESModules: isEnvDevelopment || isEnvProduction,
// Undocumented option that lets us encapsulate our runtime, ensuring
// the correct version is used
// https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
absoluteRuntime: absoluteRuntimePath,
},
],
// Adds syntax support for import()
require('@babel/plugin-syntax-dynamic-import').default,
}
]
]
const plugins = [
require('@babel/plugin-syntax-dynamic-import'),
[
require('@babel/plugin-proposal-object-rest-spread'),
{
useBuiltIns: true
}
],
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
require('@babel/plugin-transform-runtime').default,
{
corejs: false,
helpers: false,
regenerator: true,
// https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
// We should turn this on once the lowest version of Node LTS
// supports ES Modules.
useESModules: false,
// Undocumented option that lets us encapsulate our runtime, ensuring
// the correct version is used
// https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
absoluteRuntime: path.dirname(
require.resolve('@babel/runtime/package.json')
)
}
],
}
]
]
const plugins = [
require('@babel/plugin-syntax-dynamic-import'),
[
require('@babel/plugin-proposal-object-rest-spread'),
{
useBuiltIns: true
}
],
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
require('@babel/plugin-transform-runtime').default,
{
corejs: false,
helpers: false,
regenerator: true,
// https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
// We should turn this on once the lowest version of Node LTS
// supports ES Modules.
useESModules: false,
// Undocumented option that lets us encapsulate our runtime, ensuring
// the correct version is used
// https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
absoluteRuntime: path.dirname(
require.resolve('@babel/runtime/package.json')
)
}
],
require('@babel/plugin-proposal-optional-chaining').default,
require('@babel/plugin-proposal-nullish-coalescing-operator').default,
[require('@babel/plugin-proposal-decorators').default, {legacy: true}],
[require('@babel/plugin-proposal-class-properties').default, {loose: true}],
[
require('babel-plugin-transform-react-remove-prop-types').default,
{
wrap: true
}
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
{useBuiltIns: true} // asume Object.assign is available by browser or polyfill
],
[
require('@babel/plugin-transform-runtime').default,
{
corejs: false,
useESModules: true,
regenerator: true
}
]
])
}
opts.typescript && [require('@babel/preset-typescript').default],
].filter(Boolean)
const plugins: any[] = [
require('babel-plugin-macros'),
require('@babel/plugin-transform-destructuring').default,
[
require('@babel/plugin-proposal-class-properties').default,
{ loose: true },
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
{ useBuiltIns: true },
],
[
require('@babel/plugin-transform-runtime').default,
{ helpers: false, regenerator: true },
],
opts.parseProps && [
require('babel-plugin-react-docgen').default,
{ resolver: 'findAllExportedComponentDefinitions' },
],
require('babel-plugin-docz').default,
opts.env.prod && [
require('babel-plugin-transform-react-remove-prop-types').default,
{ removeImport: true },
],
!opts.env.test && [
require('@babel/plugin-transform-regenerator').default,
{ async: false },
],
require('@babel/plugin-syntax-dynamic-import').default,
isTestEnv && require('babel-plugin-dynamic-import-node'),
require('@babel/plugin-transform-destructuring').default,
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true
}
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
{
useBuiltIns: true
}
],
[
require('@babel/plugin-transform-runtime').default,
{
helpers: false,
regenerator: true,
corejs: false
}
],
[
require('@babel/plugin-transform-regenerator').default,
{
async: false
}
]
].filter(Boolean)
}
}
isTestEnv && require('babel-plugin-dynamic-import-node'),
require('@babel/plugin-transform-destructuring').default,
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true
}
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
{
useBuiltIns: true
}
],
[
require('@babel/plugin-transform-runtime').default,
{
helpers: false,
regenerator: true,
corejs: false
}
],
[
require('@babel/plugin-transform-regenerator').default,
{
async: false
}
],
isProductionEnv && [
require('babel-plugin-transform-react-remove-prop-types').default,
{
removeImport: true
isTestEnv && require('babel-plugin-dynamic-import-node'),
require('@babel/plugin-transform-destructuring').default,
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true,
},
],
[
require('@babel/plugin-proposal-object-rest-spread').default,
{
useBuiltIns: true,
},
],
[
require('@babel/plugin-transform-runtime').default,
{
helpers: false,
regenerator: true,
corejs: false,
},
],
[
require('@babel/plugin-transform-regenerator').default,
{
async: false,
},
],
[
require('babel-plugin-module-resolver').default,
{
root: ['./app/javascript/'],