Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
require('@babel/polyfill');
require('@babel/register')({
babelrc: false,
only: [__dirname, `${process.cwd()}/core`],
plugins: [
require('./server/translate-plugin.js'),
require('@babel/plugin-proposal-class-properties').default,
require('@babel/plugin-proposal-object-rest-spread').default,
],
presets: [
require('@babel/preset-react').default,
require('@babel/preset-env').default,
],
});
// initial check that required files are present
const chalk = require('chalk');
const fs = require('fs');
const CWD = process.cwd();
if (!fs.existsSync(`${CWD}/siteConfig.js`)) {
console.error(
chalk.red('Error: No siteConfig.js file found in website folder!'),
);
process.exit(1);
}
ie: 9,
},
// Users cannot override this behavior because this Babel
// configuration is highly tuned for ES5 support
ignoreBrowserslistConfig: true,
// If users import all core-js they're probably not concerned with
// bundle size. We shouldn't rely on magic to try and shrink it.
useBuiltIns: false,
// Do not transform modules to CJS
modules: false,
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
},
],
[
require('@babel/preset-react').default,
{
// Adds component stack to warning messages
// Adds __self attribute to JSX which React will use for some warnings
development: isEnvDevelopment || isEnvTest,
// Will use the native built-in instead of trying to polyfill
// behavior for any plugins that require one.
useBuiltIns: true,
},
],
isTypeScriptEnabled && [require('@babel/preset-typescript').default],
].filter(Boolean),
plugins: [
// Strip flow types before any other transform, emulating the behavior
// order as-if the browser supported all of the succeeding features
// https://github.com/facebook/create-react-app/pull/5182
// We will conditionally enable this plugin below in overrides as it clashes with
return [
[
require('@babel/preset-env').default,
{
debug: false,
ignoreBrowserslistConfig: true,
loose: true,
modules: false,
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
targets: getTargets({targets}),
useBuiltIns: false
}
],
[require('@babel/preset-react').default, {useBuiltIns: true}]
]
}
const preset = buildGlobalPreset(api, {
...passDownOpts,
'@babel/preset-env': buildEsModules ? {
...passDownOpts['@babel/preset-env'],
targets: 'maintained node versions',
modules: 'commonjs',
} : {},
'@babel/plugin-transform-runtime': {
useESModules: !buildEsModules,
},
});
preset.presets.push(
[require('@babel/preset-react').default, {
development: process.env.BABEL_ENV !== 'production',
useBuiltIns: true,
...opts['@babel/preset-react'],
}],
);
preset.plugins.push(
require('@babel/plugin-transform-flow-strip-types').default,
[require('@babel/plugin-proposal-decorators').default, {
// TODO: migrate to non-legacy decorators
legacy: true,
// decoratorsBeforeExport: true,
}],
[require('@babel/plugin-proposal-class-properties').default, {
loose: true,
}],
let presetEnv = require('@babel/preset-env');
presetEnv = presetEnv.default ? presetEnv.default : presetEnv;
let presetReact = require('@babel/preset-react');
presetReact = presetReact.default ? presetReact.default : presetReact;
let babelPlugins = require('./babel-plugins');
babelPlugins = babelPlugins.default ? babelPlugins.default : babelPlugins;
const rule = (options = {}) => ({
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
presetEnv,
{
targets: { node: '8.11.2' },
},
let presetEnv = require('@babel/preset-env');
presetEnv = presetEnv.default ? presetEnv.default : presetEnv;
let presetReact = require('@babel/preset-react');
presetReact = presetReact.default ? presetReact.default : presetReact;
let babelPlugins = require('./babel-plugins');
babelPlugins = babelPlugins.default ? babelPlugins.default : babelPlugins;
const rule = options => ({
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
presetEnv,
{
targets: { node: '8.11.2' },
},
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
require('@babel/register')({
babelrc: false,
only: [__dirname, `${process.cwd()}/core`],
plugins: [
require('./server/translate-plugin.js'),
require('@babel/plugin-proposal-class-properties').default,
require('@babel/plugin-proposal-object-rest-spread').default,
],
presets: [
require('@babel/preset-react').default,
require('@babel/preset-env').default,
],
});
const program = require('commander');
const chalk = require('chalk');
const glob = require('glob');
const fs = require('fs-extra');
const mkdirp = require('mkdirp');
const path = require('path');
const readMetadata = require('./server/readMetadata.js');
const utils = require('./server/utils.js');
const versionFallback = require('./server/versionFallback.js');
const metadataUtils = require('./server/metadataUtils.js');
const env = require('./server/env.js');
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
require('@babel/preset-env').default,
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
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,
isTestEnv && require('babel-plugin-dynamic-import-node'),
require('@babel/plugin-transform-destructuring').default,
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true
}
node: 'current'
}
}
],
(isProductionEnv || isDevelopmentEnv) && [
require('@babel/preset-env').default,
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
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,
isTestEnv && require('babel-plugin-dynamic-import-node'),
require('@babel/plugin-transform-destructuring').default,
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true
}