diff --git a/Makefile b/Makefile index 0664763b8d..1a52c4cef8 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ SOURCES = packages codemods build: clean clean-lib ./node_modules/.bin/gulp build + node ./packages/babel-standalone/scripts/generate.js node ./packages/babel-types/scripts/generateTypeHelpers.js # call build again as the generated files might need to be compiled again. ./node_modules/.bin/gulp build diff --git a/packages/babel-standalone/scripts/generate.js b/packages/babel-standalone/scripts/generate.js new file mode 100644 index 0000000000..a1c1cafb21 --- /dev/null +++ b/packages/babel-standalone/scripts/generate.js @@ -0,0 +1,37 @@ +// @flow +const pluginConfig = require("./pluginConfig.json"); +const path = require("path"); +const chalk = require("chalk"); +const camelCase = require("lodash/camelCase"); +const format = require("../../../scripts/utils/formatCode"); +const writeFile = require("../../../scripts/utils/writeFileAndMkDir"); + +const outputFile = path.join(__dirname, "../src/generated/plugins.js"); + +console.log("Generating @babel/standalone files"); + +let imports = ""; +let list = ""; +let allList = ""; + +for (const plugin of pluginConfig) { + const camelPlugin = camelCase(plugin); + imports += `import ${camelPlugin} from "@babel/plugin-${plugin}";`; + list += `${camelPlugin},`; + allList += `"${plugin}": ${camelPlugin},`; +} + +const fileContent = `// @flow +/* + * This file is auto-generated! Do not modify it directly. + * To re-generate run 'make build' + */ +${imports} + +export {${list}}; + +export const all = {${allList}}; +`; + +writeFile(outputFile, format(fileContent, outputFile)); +console.log(` ${chalk.green("✔")} Generated plugin list`); diff --git a/packages/babel-standalone/scripts/pluginConfig.json b/packages/babel-standalone/scripts/pluginConfig.json new file mode 100644 index 0000000000..812947393c --- /dev/null +++ b/packages/babel-standalone/scripts/pluginConfig.json @@ -0,0 +1,85 @@ +[ + "external-helpers", + "syntax-async-generators", + "syntax-class-properties", + "syntax-decorators", + "syntax-do-expressions", + "syntax-dynamic-import", + "syntax-export-default-from", + "syntax-export-namespace-from", + "syntax-flow", + "syntax-function-bind", + "syntax-function-sent", + "syntax-import-meta", + "syntax-jsx", + "syntax-object-rest-spread", + "syntax-optional-catch-binding", + "syntax-pipeline-operator", + "syntax-typescript", + "proposal-async-generator-functions", + "proposal-class-properties", + "proposal-decorators", + "proposal-do-expressions", + "proposal-export-default-from", + "proposal-export-namespace-from", + "proposal-function-bind", + "proposal-function-sent", + "proposal-json-strings", + "proposal-logical-assignment-operators", + "proposal-nullish-coalescing-operator", + "proposal-numeric-separator", + "proposal-object-rest-spread", + "proposal-optional-catch-binding", + "proposal-optional-chaining", + "proposal-pipeline-operator", + "proposal-private-methods", + "proposal-throw-expressions", + "proposal-unicode-property-regex", + "transform-async-to-generator", + "transform-arrow-functions", + "transform-block-scoped-functions", + "transform-block-scoping", + "transform-classes", + "transform-computed-properties", + "transform-destructuring", + "transform-dotall-regex", + "transform-duplicate-keys", + "transform-exponentiation-operator", + "transform-flow-comments", + "transform-flow-strip-types", + "transform-for-of", + "transform-function-name", + "transform-instanceof", + "transform-jscript", + "transform-literals", + "transform-member-expression-literals", + "transform-modules-amd", + "transform-modules-commonjs", + "transform-modules-systemjs", + "transform-modules-umd", + "transform-new-target", + "transform-object-assign", + "transform-object-super", + "transform-object-set-prototype-of-to-assign", + "transform-parameters", + "transform-property-literals", + "transform-property-mutators", + "transform-proto-to-assign", + "transform-react-constant-elements", + "transform-react-display-name", + "transform-react-inline-elements", + "transform-react-jsx", + "transform-react-jsx-compat", + "transform-react-jsx-self", + "transform-react-jsx-source", + "transform-regenerator", + "transform-runtime", + "transform-shorthand-properties", + "transform-spread", + "transform-sticky-regex", + "transform-strict-mode", + "transform-template-literals", + "transform-typeof-symbol", + "transform-typescript", + "transform-unicode-regex" +] diff --git a/packages/babel-standalone/src/generated/plugins.js b/packages/babel-standalone/src/generated/plugins.js new file mode 100644 index 0000000000..2e2e575768 --- /dev/null +++ b/packages/babel-standalone/src/generated/plugins.js @@ -0,0 +1,256 @@ +// @flow +import externalHelpers from "@babel/plugin-external-helpers"; +import syntaxAsyncGenerators from "@babel/plugin-syntax-async-generators"; +import syntaxClassProperties from "@babel/plugin-syntax-class-properties"; +import syntaxDecorators from "@babel/plugin-syntax-decorators"; +import syntaxDoExpressions from "@babel/plugin-syntax-do-expressions"; +import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import"; +import syntaxExportDefaultFrom from "@babel/plugin-syntax-export-default-from"; +import syntaxExportNamespaceFrom from "@babel/plugin-syntax-export-namespace-from"; +import syntaxFlow from "@babel/plugin-syntax-flow"; +import syntaxFunctionBind from "@babel/plugin-syntax-function-bind"; +import syntaxFunctionSent from "@babel/plugin-syntax-function-sent"; +import syntaxImportMeta from "@babel/plugin-syntax-import-meta"; +import syntaxJsx from "@babel/plugin-syntax-jsx"; +import syntaxObjectRestSpread from "@babel/plugin-syntax-object-rest-spread"; +import syntaxOptionalCatchBinding from "@babel/plugin-syntax-optional-catch-binding"; +import syntaxPipelineOperator from "@babel/plugin-syntax-pipeline-operator"; +import syntaxTypescript from "@babel/plugin-syntax-typescript"; +import proposalAsyncGeneratorFunctions from "@babel/plugin-proposal-async-generator-functions"; +import proposalClassProperties from "@babel/plugin-proposal-class-properties"; +import proposalDecorators from "@babel/plugin-proposal-decorators"; +import proposalDoExpressions from "@babel/plugin-proposal-do-expressions"; +import proposalExportDefaultFrom from "@babel/plugin-proposal-export-default-from"; +import proposalExportNamespaceFrom from "@babel/plugin-proposal-export-namespace-from"; +import proposalFunctionBind from "@babel/plugin-proposal-function-bind"; +import proposalFunctionSent from "@babel/plugin-proposal-function-sent"; +import proposalJsonStrings from "@babel/plugin-proposal-json-strings"; +import proposalLogicalAssignmentOperators from "@babel/plugin-proposal-logical-assignment-operators"; +import proposalNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator"; +import proposalNumericSeparator from "@babel/plugin-proposal-numeric-separator"; +import proposalObjectRestSpread from "@babel/plugin-proposal-object-rest-spread"; +import proposalOptionalCatchBinding from "@babel/plugin-proposal-optional-catch-binding"; +import proposalOptionalChaining from "@babel/plugin-proposal-optional-chaining"; +import proposalPipelineOperator from "@babel/plugin-proposal-pipeline-operator"; +import proposalPrivateMethods from "@babel/plugin-proposal-private-methods"; +import proposalThrowExpressions from "@babel/plugin-proposal-throw-expressions"; +import proposalUnicodePropertyRegex from "@babel/plugin-proposal-unicode-property-regex"; +import transformAsyncToGenerator from "@babel/plugin-transform-async-to-generator"; +import transformArrowFunctions from "@babel/plugin-transform-arrow-functions"; +import transformBlockScopedFunctions from "@babel/plugin-transform-block-scoped-functions"; +import transformBlockScoping from "@babel/plugin-transform-block-scoping"; +import transformClasses from "@babel/plugin-transform-classes"; +import transformComputedProperties from "@babel/plugin-transform-computed-properties"; +import transformDestructuring from "@babel/plugin-transform-destructuring"; +import transformDotallRegex from "@babel/plugin-transform-dotall-regex"; +import transformDuplicateKeys from "@babel/plugin-transform-duplicate-keys"; +import transformExponentiationOperator from "@babel/plugin-transform-exponentiation-operator"; +import transformFlowComments from "@babel/plugin-transform-flow-comments"; +import transformFlowStripTypes from "@babel/plugin-transform-flow-strip-types"; +import transformForOf from "@babel/plugin-transform-for-of"; +import transformFunctionName from "@babel/plugin-transform-function-name"; +import transformInstanceof from "@babel/plugin-transform-instanceof"; +import transformJscript from "@babel/plugin-transform-jscript"; +import transformLiterals from "@babel/plugin-transform-literals"; +import transformMemberExpressionLiterals from "@babel/plugin-transform-member-expression-literals"; +import transformModulesAmd from "@babel/plugin-transform-modules-amd"; +import transformModulesCommonjs from "@babel/plugin-transform-modules-commonjs"; +import transformModulesSystemjs from "@babel/plugin-transform-modules-systemjs"; +import transformModulesUmd from "@babel/plugin-transform-modules-umd"; +import transformNewTarget from "@babel/plugin-transform-new-target"; +import transformObjectAssign from "@babel/plugin-transform-object-assign"; +import transformObjectSuper from "@babel/plugin-transform-object-super"; +import transformObjectSetPrototypeOfToAssign from "@babel/plugin-transform-object-set-prototype-of-to-assign"; +import transformParameters from "@babel/plugin-transform-parameters"; +import transformPropertyLiterals from "@babel/plugin-transform-property-literals"; +import transformPropertyMutators from "@babel/plugin-transform-property-mutators"; +import transformProtoToAssign from "@babel/plugin-transform-proto-to-assign"; +import transformReactConstantElements from "@babel/plugin-transform-react-constant-elements"; +import transformReactDisplayName from "@babel/plugin-transform-react-display-name"; +import transformReactInlineElements from "@babel/plugin-transform-react-inline-elements"; +import transformReactJsx from "@babel/plugin-transform-react-jsx"; +import transformReactJsxCompat from "@babel/plugin-transform-react-jsx-compat"; +import transformReactJsxSelf from "@babel/plugin-transform-react-jsx-self"; +import transformReactJsxSource from "@babel/plugin-transform-react-jsx-source"; +import transformRegenerator from "@babel/plugin-transform-regenerator"; +import transformRuntime from "@babel/plugin-transform-runtime"; +import transformShorthandProperties from "@babel/plugin-transform-shorthand-properties"; +import transformSpread from "@babel/plugin-transform-spread"; +import transformStickyRegex from "@babel/plugin-transform-sticky-regex"; +import transformStrictMode from "@babel/plugin-transform-strict-mode"; +import transformTemplateLiterals from "@babel/plugin-transform-template-literals"; +import transformTypeofSymbol from "@babel/plugin-transform-typeof-symbol"; +import transformTypescript from "@babel/plugin-transform-typescript"; +import transformUnicodeRegex from "@babel/plugin-transform-unicode-regex"; + +export { + externalHelpers, + syntaxAsyncGenerators, + syntaxClassProperties, + syntaxDecorators, + syntaxDoExpressions, + syntaxDynamicImport, + syntaxExportDefaultFrom, + syntaxExportNamespaceFrom, + syntaxFlow, + syntaxFunctionBind, + syntaxFunctionSent, + syntaxImportMeta, + syntaxJsx, + syntaxObjectRestSpread, + syntaxOptionalCatchBinding, + syntaxPipelineOperator, + syntaxTypescript, + proposalAsyncGeneratorFunctions, + proposalClassProperties, + proposalDecorators, + proposalDoExpressions, + proposalExportDefaultFrom, + proposalExportNamespaceFrom, + proposalFunctionBind, + proposalFunctionSent, + proposalJsonStrings, + proposalLogicalAssignmentOperators, + proposalNullishCoalescingOperator, + proposalNumericSeparator, + proposalObjectRestSpread, + proposalOptionalCatchBinding, + proposalOptionalChaining, + proposalPipelineOperator, + proposalPrivateMethods, + proposalThrowExpressions, + proposalUnicodePropertyRegex, + transformAsyncToGenerator, + transformArrowFunctions, + transformBlockScopedFunctions, + transformBlockScoping, + transformClasses, + transformComputedProperties, + transformDestructuring, + transformDotallRegex, + transformDuplicateKeys, + transformExponentiationOperator, + transformFlowComments, + transformFlowStripTypes, + transformForOf, + transformFunctionName, + transformInstanceof, + transformJscript, + transformLiterals, + transformMemberExpressionLiterals, + transformModulesAmd, + transformModulesCommonjs, + transformModulesSystemjs, + transformModulesUmd, + transformNewTarget, + transformObjectAssign, + transformObjectSuper, + transformObjectSetPrototypeOfToAssign, + transformParameters, + transformPropertyLiterals, + transformPropertyMutators, + transformProtoToAssign, + transformReactConstantElements, + transformReactDisplayName, + transformReactInlineElements, + transformReactJsx, + transformReactJsxCompat, + transformReactJsxSelf, + transformReactJsxSource, + transformRegenerator, + transformRuntime, + transformShorthandProperties, + transformSpread, + transformStickyRegex, + transformStrictMode, + transformTemplateLiterals, + transformTypeofSymbol, + transformTypescript, + transformUnicodeRegex, +}; + +export const all = { + "external-helpers": externalHelpers, + "syntax-async-generators": syntaxAsyncGenerators, + "syntax-class-properties": syntaxClassProperties, + "syntax-decorators": syntaxDecorators, + "syntax-do-expressions": syntaxDoExpressions, + "syntax-dynamic-import": syntaxDynamicImport, + "syntax-export-default-from": syntaxExportDefaultFrom, + "syntax-export-namespace-from": syntaxExportNamespaceFrom, + "syntax-flow": syntaxFlow, + "syntax-function-bind": syntaxFunctionBind, + "syntax-function-sent": syntaxFunctionSent, + "syntax-import-meta": syntaxImportMeta, + "syntax-jsx": syntaxJsx, + "syntax-object-rest-spread": syntaxObjectRestSpread, + "syntax-optional-catch-binding": syntaxOptionalCatchBinding, + "syntax-pipeline-operator": syntaxPipelineOperator, + "syntax-typescript": syntaxTypescript, + "proposal-async-generator-functions": proposalAsyncGeneratorFunctions, + "proposal-class-properties": proposalClassProperties, + "proposal-decorators": proposalDecorators, + "proposal-do-expressions": proposalDoExpressions, + "proposal-export-default-from": proposalExportDefaultFrom, + "proposal-export-namespace-from": proposalExportNamespaceFrom, + "proposal-function-bind": proposalFunctionBind, + "proposal-function-sent": proposalFunctionSent, + "proposal-json-strings": proposalJsonStrings, + "proposal-logical-assignment-operators": proposalLogicalAssignmentOperators, + "proposal-nullish-coalescing-operator": proposalNullishCoalescingOperator, + "proposal-numeric-separator": proposalNumericSeparator, + "proposal-object-rest-spread": proposalObjectRestSpread, + "proposal-optional-catch-binding": proposalOptionalCatchBinding, + "proposal-optional-chaining": proposalOptionalChaining, + "proposal-pipeline-operator": proposalPipelineOperator, + "proposal-private-methods": proposalPrivateMethods, + "proposal-throw-expressions": proposalThrowExpressions, + "proposal-unicode-property-regex": proposalUnicodePropertyRegex, + "transform-async-to-generator": transformAsyncToGenerator, + "transform-arrow-functions": transformArrowFunctions, + "transform-block-scoped-functions": transformBlockScopedFunctions, + "transform-block-scoping": transformBlockScoping, + "transform-classes": transformClasses, + "transform-computed-properties": transformComputedProperties, + "transform-destructuring": transformDestructuring, + "transform-dotall-regex": transformDotallRegex, + "transform-duplicate-keys": transformDuplicateKeys, + "transform-exponentiation-operator": transformExponentiationOperator, + "transform-flow-comments": transformFlowComments, + "transform-flow-strip-types": transformFlowStripTypes, + "transform-for-of": transformForOf, + "transform-function-name": transformFunctionName, + "transform-instanceof": transformInstanceof, + "transform-jscript": transformJscript, + "transform-literals": transformLiterals, + "transform-member-expression-literals": transformMemberExpressionLiterals, + "transform-modules-amd": transformModulesAmd, + "transform-modules-commonjs": transformModulesCommonjs, + "transform-modules-systemjs": transformModulesSystemjs, + "transform-modules-umd": transformModulesUmd, + "transform-new-target": transformNewTarget, + "transform-object-assign": transformObjectAssign, + "transform-object-super": transformObjectSuper, + "transform-object-set-prototype-of-to-assign": transformObjectSetPrototypeOfToAssign, + "transform-parameters": transformParameters, + "transform-property-literals": transformPropertyLiterals, + "transform-property-mutators": transformPropertyMutators, + "transform-proto-to-assign": transformProtoToAssign, + "transform-react-constant-elements": transformReactConstantElements, + "transform-react-display-name": transformReactDisplayName, + "transform-react-inline-elements": transformReactInlineElements, + "transform-react-jsx": transformReactJsx, + "transform-react-jsx-compat": transformReactJsxCompat, + "transform-react-jsx-self": transformReactJsxSelf, + "transform-react-jsx-source": transformReactJsxSource, + "transform-regenerator": transformRegenerator, + "transform-runtime": transformRuntime, + "transform-shorthand-properties": transformShorthandProperties, + "transform-spread": transformSpread, + "transform-sticky-regex": transformStickyRegex, + "transform-strict-mode": transformStrictMode, + "transform-template-literals": transformTemplateLiterals, + "transform-typeof-symbol": transformTypeofSymbol, + "transform-typescript": transformTypescript, + "transform-unicode-regex": transformUnicodeRegex, +}; diff --git a/packages/babel-standalone/src/index.js b/packages/babel-standalone/src/index.js index 5804409ad0..d7ed72afd2 100644 --- a/packages/babel-standalone/src/index.js +++ b/packages/babel-standalone/src/index.js @@ -4,12 +4,26 @@ * plugins, instead explicitly registering all the available plugins and * presets, and requiring custom ones to be registered through `registerPlugin` * and `registerPreset` respectively. + * @flow */ /* global VERSION */ /* eslint-disable max-len */ -import * as Babel from "@babel/core"; +import { + transformFromAst as babelTransformFromAst, + transform as babelTransform, + buildExternalHelpers as babelBuildExternalHelpers, +} from "@babel/core"; +import { all } from "./generated/plugins"; +import preset2015 from "./preset-es2015"; +import presetStage0 from "./preset-stage-0"; +import presetStage1 from "./preset-stage-1"; +import presetStage2 from "./preset-stage-2"; +import presetStage3 from "./preset-stage-3"; +import presetReact from "@babel/preset-react"; +import presetFlow from "@babel/preset-flow"; +import presetTypescript from "@babel/preset-typescript"; import { runScripts } from "./transformScriptTags"; @@ -84,20 +98,20 @@ function processOptions(options) { }; } -export function transform(code, options) { - return Babel.transform(code, processOptions(options)); +export function transform(code: string, options: Object) { + return babelTransform(code, processOptions(options)); } -export function transformFromAst(ast, code, options) { - return Babel.transformFromAst(ast, code, processOptions(options)); +export function transformFromAst(ast: Object, code: string, options: Object) { + return babelTransformFromAst(ast, code, processOptions(options)); } export const availablePlugins = {}; export const availablePresets = {}; -export const buildExternalHelpers = Babel.buildExternalHelpers; +export const buildExternalHelpers = babelBuildExternalHelpers; /** * Registers a named plugin for use with Babel. */ -export function registerPlugin(name, plugin) { +export function registerPlugin(name: string, plugin: Object | Function): void { if (availablePlugins.hasOwnProperty(name)) { console.warn( `A plugin named "${name}" is already registered, it will be overridden`, @@ -109,7 +123,9 @@ export function registerPlugin(name, plugin) { * Registers multiple plugins for use with Babel. `newPlugins` should be an object where the key * is the name of the plugin, and the value is the plugin itself. */ -export function registerPlugins(newPlugins) { +export function registerPlugins(newPlugins: { + [string]: Object | Function, +}): void { Object.keys(newPlugins).forEach(name => registerPlugin(name, newPlugins[name]), ); @@ -118,7 +134,7 @@ export function registerPlugins(newPlugins) { /** * Registers a named preset for use with Babel. */ -export function registerPreset(name, preset) { +export function registerPreset(name: string, preset: Object | Function): void { if (availablePresets.hasOwnProperty(name)) { console.warn( `A preset named "${name}" is already registered, it will be overridden`, @@ -130,7 +146,9 @@ export function registerPreset(name, preset) { * Registers multiple presets for use with Babel. `newPresets` should be an object where the key * is the name of the preset, and the value is the preset itself. */ -export function registerPresets(newPresets) { +export function registerPresets(newPresets: { + [string]: Object | Function, +}): void { Object.keys(newPresets).forEach(name => registerPreset(name, newPresets[name]), ); @@ -139,90 +157,13 @@ export function registerPresets(newPresets) { // All the plugins we should bundle // Want to get rid of this long whitelist of plugins? // Wait! Please read https://github.com/babel/babel/pull/6177 first. -registerPlugins({ - "external-helpers": require("@babel/plugin-external-helpers"), - "syntax-async-generators": require("@babel/plugin-syntax-async-generators"), - "syntax-class-properties": require("@babel/plugin-syntax-class-properties"), - "syntax-decorators": require("@babel/plugin-syntax-decorators"), - "syntax-do-expressions": require("@babel/plugin-syntax-do-expressions"), - "syntax-dynamic-import": require("@babel/plugin-syntax-dynamic-import"), - "syntax-export-default-from": require("@babel/plugin-syntax-export-default-from"), - "syntax-export-namespace-from": require("@babel/plugin-syntax-export-namespace-from"), - "syntax-flow": require("@babel/plugin-syntax-flow"), - "syntax-function-bind": require("@babel/plugin-syntax-function-bind"), - "syntax-function-sent": require("@babel/plugin-syntax-function-sent"), - "syntax-import-meta": require("@babel/plugin-syntax-import-meta"), - "syntax-jsx": require("@babel/plugin-syntax-jsx"), - "syntax-object-rest-spread": require("@babel/plugin-syntax-object-rest-spread"), - "syntax-optional-catch-binding": require("@babel/plugin-syntax-optional-catch-binding"), - "syntax-pipeline-operator": require("@babel/plugin-syntax-pipeline-operator"), - "syntax-typescript": require("@babel/plugin-syntax-typescript"), - "transform-async-to-generator": require("@babel/plugin-transform-async-to-generator"), - "proposal-async-generator-functions": require("@babel/plugin-proposal-async-generator-functions"), - "proposal-class-properties": require("@babel/plugin-proposal-class-properties"), - "proposal-decorators": require("@babel/plugin-proposal-decorators"), - "proposal-do-expressions": require("@babel/plugin-proposal-do-expressions"), - "proposal-export-default-from": require("@babel/plugin-proposal-export-default-from"), - "proposal-export-namespace-from": require("@babel/plugin-proposal-export-namespace-from"), - "proposal-pipeline-operator": require("@babel/plugin-proposal-pipeline-operator"), - "proposal-private-methods": require("@babel/plugin-proposal-private-methods"), - "transform-arrow-functions": require("@babel/plugin-transform-arrow-functions"), - "transform-block-scoped-functions": require("@babel/plugin-transform-block-scoped-functions"), - "transform-block-scoping": require("@babel/plugin-transform-block-scoping"), - "transform-classes": require("@babel/plugin-transform-classes"), - "transform-computed-properties": require("@babel/plugin-transform-computed-properties"), - "transform-destructuring": require("@babel/plugin-transform-destructuring"), - "transform-dotall-regex": require("@babel/plugin-transform-dotall-regex"), - "transform-duplicate-keys": require("@babel/plugin-transform-duplicate-keys"), - "transform-for-of": require("@babel/plugin-transform-for-of"), - "transform-function-name": require("@babel/plugin-transform-function-name"), - "transform-instanceof": require("@babel/plugin-transform-instanceof"), - "transform-literals": require("@babel/plugin-transform-literals"), - "transform-modules-amd": require("@babel/plugin-transform-modules-amd"), - "transform-modules-commonjs": require("@babel/plugin-transform-modules-commonjs"), - "transform-modules-systemjs": require("@babel/plugin-transform-modules-systemjs"), - "transform-modules-umd": require("@babel/plugin-transform-modules-umd"), - "transform-object-super": require("@babel/plugin-transform-object-super"), - "transform-parameters": require("@babel/plugin-transform-parameters"), - "transform-shorthand-properties": require("@babel/plugin-transform-shorthand-properties"), - "transform-spread": require("@babel/plugin-transform-spread"), - "transform-sticky-regex": require("@babel/plugin-transform-sticky-regex"), - "transform-template-literals": require("@babel/plugin-transform-template-literals"), - "transform-typeof-symbol": require("@babel/plugin-transform-typeof-symbol"), - "transform-typescript": require("@babel/plugin-transform-typescript"), - "transform-unicode-regex": require("@babel/plugin-transform-unicode-regex"), - "transform-member-expression-literals": require("@babel/plugin-transform-member-expression-literals"), - "transform-property-literals": require("@babel/plugin-transform-property-literals"), - "transform-property-mutators": require("@babel/plugin-transform-property-mutators"), - "transform-exponentiation-operator": require("@babel/plugin-transform-exponentiation-operator"), - "transform-flow-comments": require("@babel/plugin-transform-flow-comments"), - "transform-flow-strip-types": require("@babel/plugin-transform-flow-strip-types"), - "proposal-function-bind": require("@babel/plugin-proposal-function-bind"), - "transform-jscript": require("@babel/plugin-transform-jscript"), - "transform-new-target": require("@babel/plugin-transform-new-target"), - "transform-object-assign": require("@babel/plugin-transform-object-assign"), - "proposal-object-rest-spread": require("@babel/plugin-proposal-object-rest-spread"), - "transform-object-set-prototype-of-to-assign": require("@babel/plugin-transform-object-set-prototype-of-to-assign"), - "proposal-optional-catch-binding": require("@babel/plugin-proposal-optional-catch-binding"), - "transform-proto-to-assign": require("@babel/plugin-transform-proto-to-assign"), - "transform-react-constant-elements": require("@babel/plugin-transform-react-constant-elements"), - "transform-react-display-name": require("@babel/plugin-transform-react-display-name"), - "transform-react-inline-elements": require("@babel/plugin-transform-react-inline-elements"), - "transform-react-jsx": require("@babel/plugin-transform-react-jsx"), - "transform-react-jsx-compat": require("@babel/plugin-transform-react-jsx-compat"), - "transform-react-jsx-self": require("@babel/plugin-transform-react-jsx-self"), - "transform-react-jsx-source": require("@babel/plugin-transform-react-jsx-source"), - "transform-regenerator": require("@babel/plugin-transform-regenerator"), - "transform-runtime": require("@babel/plugin-transform-runtime"), - "transform-strict-mode": require("@babel/plugin-transform-strict-mode"), - "proposal-unicode-property-regex": require("@babel/plugin-proposal-unicode-property-regex"), -}); +registerPlugins(all); // All the presets we should bundle // Want to get rid of this whitelist of presets? // Wait! Please read https://github.com/babel/babel/pull/6177 first. registerPresets({ - es2015: require("./preset-es2015"), + es2015: preset2015, es2016: () => { return { plugins: [availablePlugins["transform-exponentiation-operator"]], @@ -233,22 +174,23 @@ registerPresets({ plugins: [availablePlugins["transform-async-to-generator"]], }; }, - react: require("@babel/preset-react"), - "stage-0": require("./preset-stage-0"), - "stage-1": require("./preset-stage-1"), - "stage-2": require("./preset-stage-2"), - "stage-3": require("./preset-stage-3"), + react: presetReact, + "stage-0": presetStage0, + "stage-1": presetStage1, + "stage-2": presetStage2, + "stage-3": presetStage3, "es2015-loose": { - presets: [[require("./preset-es2015"), { loose: true }]], + presets: [[preset2015, { loose: true }]], }, // ES2015 preset with es2015-modules-commonjs removed "es2015-no-commonjs": { - presets: [[require("./preset-es2015"), { modules: false }]], + presets: [[preset2015, { modules: false }]], }, - typescript: require("@babel/preset-typescript"), - flow: require("@babel/preset-flow"), + typescript: presetTypescript, + flow: presetFlow, }); +// $FlowIgnore export const version = VERSION; function onDOMContentLoaded() { @@ -265,7 +207,7 @@ if (typeof window !== "undefined" && window && window.addEventListener) { * Transform