rsnext/packages/next/bundles/babel/bundle.js
Dale Bustad c2dfe40296
Babel fast mode (#23760)
@timneutkens it'd be great to get your input.

These changes introduce a new Babel loader that eliminates much of the existing overhead, resulting in better HMR speeds. 
 Multithreading is still in flight, and may be omitted if speed improvements end up being negligible.  For now, the new loader is hidden behind an `experimental` flag.

Items to be completed before this PR is ready to merge:

- [x] reconfigure `ncc` to precompile the parts of `@babel/core` and `@babel/traverse` that we're accessing directly
- [x] change `@babel/core/...` imports to `ncc`ed version
- [x] ~~measure multithreading (not currently pushed) functionality, and include the functionality depending on the results~~ I'll open a separate PR for this
- [x] ensure TypeScript is happy with all imports as final step (`--no-verify` was used to bypass)

There will be two follow-up PRs:
- loader support for projects with custom `.babelrc`
- multithreaded loader (should the change we warranted after measurement)
2021-04-08 12:03:02 +00:00

119 lines
2.6 KiB
JavaScript

/* eslint-disable import/no-extraneous-dependencies */
function codeFrame() {
return require('@babel/code-frame')
}
function core() {
return require('@babel/core')
}
function coreLibConfig() {
return require('@babel/core/lib/config')
}
function coreLibNormalizeFile() {
return require('@babel/core/lib/transformation/normalize-file')
}
function coreLibNormalizeOpts() {
return require('@babel/core/lib/transformation/normalize-opts')
}
function coreLibBlockHoistPlugin() {
return require('@babel/core/lib/transformation/block-hoist-plugin')
}
function coreLibPluginPass() {
return require('@babel/core/lib/transformation/plugin-pass')
}
function traverse() {
return require('@babel/traverse')
}
function generator() {
return require('@babel/generator')
}
function pluginProposalClassProperties() {
return require('@babel/plugin-proposal-class-properties')
}
function pluginProposalExportNamespaceFrom() {
return require('@babel/plugin-proposal-export-namespace-from')
}
function pluginProposalNumericSeparator() {
return require('@babel/plugin-proposal-numeric-separator')
}
function pluginProposalObjectRestSpread() {
return require('@babel/plugin-proposal-object-rest-spread')
}
function pluginSyntaxBigint() {
return require('@babel/plugin-syntax-bigint')
}
function pluginSyntaxDynamicImport() {
return require('@babel/plugin-syntax-dynamic-import')
}
function pluginSyntaxJsx() {
return require('@babel/plugin-syntax-jsx')
}
function pluginTransformDefine() {
return require('babel-plugin-transform-define')
}
function pluginTransformModulesCommonjs() {
return require('@babel/plugin-transform-modules-commonjs')
}
function pluginTransformReactRemovePropTypes() {
return require('babel-plugin-transform-react-remove-prop-types')
}
function pluginTransformRuntime() {
return require('@babel/plugin-transform-runtime')
}
function presetEnv() {
return require('@babel/preset-env')
}
function presetReact() {
return require('@babel/preset-react')
}
function presetTypescript() {
return require('@babel/preset-typescript')
}
module.exports = {
codeFrame,
core,
coreLibConfig,
coreLibNormalizeFile,
coreLibNormalizeOpts,
coreLibBlockHoistPlugin,
coreLibPluginPass,
generator,
pluginProposalClassProperties,
pluginProposalExportNamespaceFrom,
pluginProposalNumericSeparator,
pluginProposalObjectRestSpread,
pluginSyntaxBigint,
pluginSyntaxDynamicImport,
pluginSyntaxJsx,
pluginTransformDefine,
pluginTransformModulesCommonjs,
pluginTransformReactRemovePropTypes,
pluginTransformRuntime,
presetEnv,
presetReact,
presetTypescript,
traverse,
}