Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* 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/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!'),
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const escapeRegExp = require('escape-string-regexp');
const path = require('path');
require('./node-polyfills');
var _only = [];
const PLUGINS = [
[require('@babel/plugin-transform-flow-strip-types').default],
[require('@babel/plugin-proposal-object-rest-spread').default],
[require('@babel/plugin-proposal-class-properties').default],
[require('@babel/plugin-transform-modules-commonjs').default],
[require('@babel/plugin-proposal-nullish-coalescing-operator').default],
[require('@babel/plugin-proposal-optional-catch-binding').default],
[require('@babel/plugin-proposal-optional-chaining').default],
];
if (/^v[0-7]\./.test(process.version)) {
PLUGINS.push([require('@babel/plugin-transform-async-to-generator').default]);
}
function registerOnly(onlyList) {
// This prevents `babel-register` from transforming the code of the
// plugins/presets that we are require-ing themselves before setting up the
// actual config.
require('@babel/register')({only: [], babelrc: false});
/**
* 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.
*/
/* generate the i18n/en.json file */
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 traverse = require('@babel/traverse').default;
const babylon = require('babylon');
const fs = require('fs-extra');
const glob = require('glob');
const mkdirp = require('mkdirp');
const nodePath = require('path');
const _ = require('lodash');
const readMetadata = require('./server/readMetadata.js');
return cleanList([
require('@babel/plugin-syntax-dynamic-import').default,
require('@babel/plugin-syntax-export-default-from').default,
require('@babel/plugin-syntax-export-namespace-from').default,
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
}
]
])
}
// 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
// extends helper. Note that this assumes `Object.assign` is available.
// { ...todo, completed: true }
[
require('@babel/plugin-proposal-object-rest-spread').default,
{
useBuiltIns: true,
},
],
// Polyfills the runtime needed for async/await and generators
!isEnvNode && [
require('@babel/plugin-transform-runtime').default,
{
helpers: false,
polyfill: false,
regenerator: true,
},
],
isEnvProduction && [
// Remove PropTypes from production build
require('babel-plugin-transform-react-remove-prop-types').default,
exclude: [
// already done or not needed
"transform-regenerator",
"transform-shorthand-properties",
"transform-classes",
"transform-typeof-symbol",
"transform-async-to-generator",
...((opts.env && opts.env.exclude) || [])
]
}
],
{
plugins: [
require("@babel/plugin-syntax-dynamic-import").default,
[
require("@babel/plugin-proposal-object-rest-spread").default,
{
useBuiltIns: true
}
],
process.env.EFFECTFUL_DEBUGGER_NODE &&
require("babel-plugin-dynamic-import-node")
].filter(Boolean)
}
);
const tsOpts = { allowNamespaces: opts.tsAllowNamespaces };
if (opts.jsxPragma) tsOpts.jsxPragma = opts.jsxPragma;
if (opts.typescript !== false) {
/*
result.presets.unshift({
plugins: [
require("./ts-no-consts"),
#!/usr/bin/env node
/**
* 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');
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
]
}
}
]
].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
}
],
[
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
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-private-methods").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