Reduce standalone build size#10668
Conversation
|
The size change of |
d378177 to
39b9ace
Compare
packages/babel-core/package.json
Outdated
| "version": "7.7.2", | ||
| "description": "Babel compiler core.", | ||
| "main": "lib/index.js", | ||
| "_main:used-by-babel-standalone": "src/index.js", |
There was a problem hiding this comment.
I don't like this 😆
Is it possible to use webpack's resolve instead?
There was a problem hiding this comment.
By using resolve.alias like the other packages, webpack will ignore the browsers field in package.json.
There was a problem hiding this comment.
I'm not sure I follow. If we did something like this, wouldn't it work?
resolve: {
alias: {
"@babel/core$": "packages/babel-core/src/index.js"
}
}a7d6bf4 to
a27059a
Compare
# Conflicts: # babel.config.js
credits to Nicolò
a27059a to
1c1119f
Compare
| const babelRuntimePackageJSONPath = require.resolve( | ||
| "@babel/runtime/package.json" | ||
| ); | ||
| const path = require("path"); |
There was a problem hiding this comment.
It's a simple question. What is the advantage of declaring within this scope rather than at the top?
There was a problem hiding this comment.
Not a strong reason: require("path") is used only when building babel-*-standalone. However, this config is shared with other building process (build/jest), by doing so we could avoid the overhead of requiring a builtin module.
In this PR we build babel-standalone against the
srcversion of@babel/*dependencies instead oflib, which is specified in theirpackage.json. By doing so thetransform-runtimecan replace babel helper calls by runtime helper imports. It is impossible to achieve this onlibversion where the helpers are inlined.Here is a brief summary on the number of inlined
function _interopRequireDefault(obj)declarations in the artifacts. (produced by this script, lower is better)Note that there are still 4 inlined
_interopRequireDefaultdeclaration not removed in@babel/standalone, all of which comes from third party dependencies, i.e.regenerator-runtime.