Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Single file expressing all Babel dependencies and applying all plugins so that they will be
* in a single webpack chunk.
*/
// @ts-ignore
import {registerPlugin, transform} from "@babel/standalone";
// @ts-ignore
import NumericSeparatorPlugin from "@babel/plugin-proposal-numeric-separator";
// @ts-ignore
import DynamicImportPlugin from "babel-plugin-dynamic-import-node";
// @ts-ignore
import ReactHotLoaderPlugin from "react-hot-loader/dist/babel.development";
registerPlugin("proposal-numeric-separator", NumericSeparatorPlugin);
registerPlugin("dynamic-import-node", DynamicImportPlugin);
registerPlugin("react-hot-loader", ReactHotLoaderPlugin);
export {transform};
// import PresetReact from '@babel/preset-react'
//$todo
// import PresetFlow from '@babel/preset-flow'
//$todo
// import PluginStrictMode from '@babel/plugin-transform-strict-mode'
//$todo
// import PluginClassProps from '@babel/plugin-proposal-class-properties'
//$todo
// import PluginNullish from '@babel/plugin-proposal-nullish-coalescing-operator'
//$todo
// import PluginOptional from '@babel/plugin-proposal-optional-chaining'
//$todo
import {transform, registerPlugin, registerPreset} from '@babel/standalone'
import {babelOptions} from './domain'
registerPlugin('syntax-bigint', PluginBigInt)
// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)
// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
// '@babel/plugin-proposal-nullish-coalescing-operator',
// PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)
registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
visitor: {
import {babelOptions} from './domain'
registerPlugin('syntax-bigint', PluginBigInt)
// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)
// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
// '@babel/plugin-proposal-nullish-coalescing-operator',
// PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)
registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
visitor: {
ImportDeclaration(path) {
path.remove()
},
ExportDefaultDeclaration(path) {
path.remove()
},
ExportNamedDeclaration(path) {
if (babel.types.isVariableDeclaration(path.node.declaration)) {
path.replaceWith(path.node.declaration)
} else {
path.remove()
}
},
registerPlugin('syntax-bigint', PluginBigInt)
// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)
// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
// '@babel/plugin-proposal-nullish-coalescing-operator',
// PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)
registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
visitor: {
ImportDeclaration(path) {
path.remove()
},
ExportDefaultDeclaration(path) {
path.remove()
},
ExportNamedDeclaration(path) {
if (babel.types.isVariableDeclaration(path.node.declaration)) {
path.replaceWith(path.node.declaration)
} else {
path.remove()
}
},
},
}))
registerPlugin('syntax-bigint', PluginBigInt)
// registerPreset('@babel/preset-react', PresetReact)
// registerPreset('@babel/preset-flow', PresetFlow)
// registerPlugin('@babel/plugin-proposal-class-properties', PluginClassProps)
// registerPlugin(
// '@babel/plugin-proposal-nullish-coalescing-operator',
// PluginNullish,
// )
// registerPlugin('@babel/plugin-proposal-optional-chaining', PluginOptional)
// registerPlugin('@babel/plugin-transform-strict-mode', PluginStrictMode)
registerPlugin('effector/babel-plugin', PluginEffector)
registerPlugin('effector/babel-plugin-react', PluginEffectorReact)
registerPlugin('@effector/repl-remove-imports', babel => ({
visitor: {
ImportDeclaration(path) {
path.remove()
},
ExportDefaultDeclaration(path) {
path.remove()
},
ExportNamedDeclaration(path) {
if (babel.types.isVariableDeclaration(path.node.declaration)) {
path.replaceWith(path.node.declaration)
} else {
path.remove()
}
},
},
const loopsPerTimeoutCheck = 2000;
function loopProtectCB(line) {
console.log(
`Potential infinite loop detected on line ${line}. Tests may fail if this is not changed.`
);
}
function testLoopProtectCB(line) {
console.log(
`Potential infinite loop detected on line ${line}. Tests may be failing because of this.`
);
}
Babel.registerPlugin('loopProtection', protect(protectTimeout, loopProtectCB));
Babel.registerPlugin(
'testLoopProtection',
protect(testProtectTimeout, testLoopProtectCB, loopsPerTimeoutCheck)
);
const babelOptionsJSX = {
plugins: ['loopProtection'],
presets: [presetEnv, presetReact]
};
const babelOptionsJS = {
plugins: ['testLoopProtection'],
presets: [presetEnv]
};
const babelOptionsJSPreview = {
...babelOptionsJS,
const initialize = () => {
if (initialized) {
return;
}
initialized = true;
Babel.registerPreset('@babel/preset-react', babelPresetReact);
Babel.registerPlugin('@babel/plugin-proposal-class-properties', babelPluginProposalClassProperties);
Babel.registerPlugin('@babel/plugin-proposal-object-rest-spread', babelPluginProposalObjectRestSprerad);
Babel.registerPlugin('@babel/plugin-proposal-optional-catch-binding', babelPluginProposalOptionalCatchBinding);
Babel.registerPlugin('@babel/plugin-proposal-async-generator-functions', babelPluginProposalAsyncGeneratorFunctions);
Babel.registerPlugin('@babel/plugin-proposal-numeric-separator', babelPluginProposalNumericSeparator);
Babel.registerPlugin('@babel/plugin-transform-typescript', babelPluginTransformTypeScript);
Babel.registerPlugin('@babel/plugin-transform-modules-commonjs', babelPluginTransformModulesCommonJS);
};
const initialize = () => {
if (initialized) {
return;
}
initialized = true;
Babel.registerPreset('@babel/preset-react', babelPresetReact);
Babel.registerPlugin('@babel/plugin-proposal-class-properties', babelPluginProposalClassProperties);
Babel.registerPlugin('@babel/plugin-proposal-object-rest-spread', babelPluginProposalObjectRestSprerad);
Babel.registerPlugin('@babel/plugin-proposal-optional-catch-binding', babelPluginProposalOptionalCatchBinding);
Babel.registerPlugin('@babel/plugin-proposal-async-generator-functions', babelPluginProposalAsyncGeneratorFunctions);
Babel.registerPlugin('@babel/plugin-proposal-numeric-separator', babelPluginProposalNumericSeparator);
Babel.registerPlugin('@babel/plugin-transform-typescript', babelPluginTransformTypeScript);
Babel.registerPlugin('@babel/plugin-transform-modules-commonjs', babelPluginTransformModulesCommonJS);
};
const babel = require('@babel/standalone');
const protect = require('loop-protect');
babel.registerPlugin('loopProtection', protect(100));
function transform(source) {
try {
return babel.transform(source, {
plugins: [
'loopProtection',
],
}).code
} catch (e) {
return source;
}
}
module.exports = {
loopProtect: transform,
};
const initialize = () => {
if (initialized) {
return;
}
initialized = true;
Babel.registerPreset('@babel/preset-react', babelPresetReact);
Babel.registerPlugin('@babel/plugin-proposal-class-properties', babelPluginProposalClassProperties);
Babel.registerPlugin('@babel/plugin-proposal-object-rest-spread', babelPluginProposalObjectRestSprerad);
Babel.registerPlugin('@babel/plugin-proposal-optional-catch-binding', babelPluginProposalOptionalCatchBinding);
Babel.registerPlugin('@babel/plugin-proposal-async-generator-functions', babelPluginProposalAsyncGeneratorFunctions);
Babel.registerPlugin('@babel/plugin-proposal-numeric-separator', babelPluginProposalNumericSeparator);
Babel.registerPlugin('@babel/plugin-transform-typescript', babelPluginTransformTypeScript);
Babel.registerPlugin('@babel/plugin-transform-modules-commonjs', babelPluginTransformModulesCommonJS);
};