Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*
* @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});
require('@babel/register')(config(onlyList));
}
* @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, configFile: false});
require('@babel/register')(config(onlyList));
}
export default function NextToNextServer(...args: any): PluginObj {
const commonjs = commonjsPlugin(...args)
return {
visitor: {
Program: {
exit(path: NodePath, state) {
let foundModuleExports = false
path.traverse({
MemberExpression(path: any) {
if (path.node.object.name !== 'module') return
if (path.node.property.name !== 'exports') return
foundModuleExports = true
},
})
if (!foundModuleExports) {
return
}
const { join } = require('path');
const ModuleRewrite = require('babel-plugin-module-rewrite').default;
const ObjectRestSpread = require('@babel/plugin-proposal-object-rest-spread').default;
const ClassProperties = require('@babel/plugin-proposal-class-properties').default;
const ModulesCommonJS = require('@babel/plugin-transform-modules-commonjs').default;
const AddModuleExports = require('babel-plugin-add-module-exports');
const Classes = require('@babel/plugin-transform-classes').default;
const BlockScoping = require('@babel/plugin-transform-block-scoping').default;
const ArrowFunctions = require('@babel/plugin-transform-arrow-functions').default;
const ShorthandProperties = require('@babel/plugin-transform-shorthand-properties').default;
const ObjectDestructuring = require('@babel/plugin-transform-destructuring').default;
const Parameters = require('@babel/plugin-transform-parameters').default;
const Spread = require('@babel/plugin-transform-spread').default;
const TemplateLiterals = require('@babel/plugin-transform-template-literals').default;
const ForOf = require('@babel/plugin-transform-for-of').default;
const ComputedProperties = require('@babel/plugin-transform-computed-properties').default;
const ElementClasses = require('babel-plugin-transform-custom-element-classes');
const esmFunc = join(__dirname, 'utils/replace-esm.js');
const cjsFunc = join(__dirname, 'utils/replace-cjs.js');