Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Remove this once that babel issue is fixed
let babelHelperVersion = {}
try {
// 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
function testOnlyBabel(babel: any, babelOptions: any, nodeVersion: string) {
// out test dir can be located outside of electron-builder node_modules and babel cannot resolve string names of preset
babelOptions.presets = [
[require("@babel/preset-env").default, {targets: {node: nodeVersion}}],
require("@babel/preset-react"),
]
babelOptions.plugins = [
// stage 0
require("@babel/plugin-proposal-function-bind").default,
// stage 1
require("@babel/plugin-proposal-export-default-from").default,
require("@babel/plugin-proposal-logical-assignment-operators").default,
[require("@babel/plugin-proposal-optional-chaining").default, {loose: false}],
[require("@babel/plugin-proposal-pipeline-operator").default, {proposal: "minimal"}],
[require("@babel/plugin-proposal-nullish-coalescing-operator").default, {loose: false}],
require("@babel/plugin-proposal-do-expressions").default,
// stage 2
[require("@babel/plugin-proposal-decorators").default, {legacy: true}],
require("@babel/plugin-proposal-function-sent").default,
require("@babel/plugin-proposal-export-namespace-from").default,
require("@babel/plugin-proposal-numeric-separator").default,
require("@babel/plugin-proposal-throw-expressions").default,
// stage 3
require("@babel/plugin-syntax-dynamic-import").default,
require("@babel/plugin-syntax-import-meta").default,
const jsFeatures = () => [
// old Stage 1
require('@babel/plugin-proposal-export-default-from').default,
// old Stage 2
[require('@babel/plugin-proposal-decorators').default, {legacy: true}],
// old Stage 3
require('@babel/plugin-syntax-dynamic-import').default,
require('@babel/plugin-syntax-import-meta').default,
[require('@babel/plugin-proposal-class-properties').default, {loose: false}],
require('@babel/plugin-proposal-json-strings').default,
];
},
],
[
'@emotion/babel-preset-css-prop',
{
sourceMap: isEnvDevelopment,
autoLabel: !isEnvProduction,
},
],
].filter(Boolean),
plugins: [
// Experimental macros support. Will be documented after it's had some time
// in the wild.
require('babel-plugin-macros').default,
// export { default } from './foo'
require('@babel/plugin-proposal-export-default-from').default,
// export * from './foo'
require('@babel/plugin-proposal-export-namespace-from').default,
// Necessary to include regardless of the environment because
// in practice some other transforms (such as object-rest-spread)
// don't work without it: https://github.com/babel/babel/issues/7215
require('@babel/plugin-transform-destructuring').default,
// class { handleClick = () => { } }
// Enable loose mode to use assignment instead of defineProperty
// See discussion in https://github.com/facebook/create-react-app/issues/4263
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true,
},
],
// The following two plugins use Object.assign directly, instead of Babel's
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
const envPreset = require('@babel/preset-env');
const reactPreset = require('@babel/preset-react');
const syntaxDynamicImport = require('@babel/plugin-syntax-dynamic-import').default;
const proposalClassProperties = require('@babel/plugin-proposal-class-properties').default;
const exportDefaultFrom = require('@babel/plugin-proposal-export-default-from').default;
const proposalOptionalChaining = require('@babel/plugin-proposal-optional-chaining').default;
const { browserlist, legacyBrowserList } = require('./browserlist');
module.exports = () => ({
env: {
modern: {
presets: [
[envPreset, {
targets: {
browsers: browserlist,
node: '10.13.0',
},
}],
],
},
module.exports = {
presets: [
[require('@babel/preset-env').default, {
targets: { node: 8 },
}]
],
plugins: [
[require('@babel/plugin-proposal-decorators').default, {
legacy: true
}],
[require('@babel/plugin-proposal-class-properties').default, {
loose: true
}],
require('@babel/plugin-proposal-object-rest-spread').default,
require('@babel/plugin-proposal-export-default-from').default,
require('@babel/plugin-proposal-export-namespace-from').default
]
}
modules: false,
exclude: ['transform-typeof-symbol']
}
],
[
require('@babel/preset-react').default,
{
development: isDevelopmentEnv || isTestEnv,
useBuiltIns: true
}
]
].filter(Boolean),
plugins: [
require('babel-plugin-macros'),
require('@babel/plugin-syntax-dynamic-import').default,
require('@babel/plugin-proposal-export-default-from').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,