Skip to content

Commit 3db849f

Browse files
committed
optim: specify version in @babel/plugin-transform-runtime
- the default is 7.0.0, but we are on a newer version, so we can use newer / more optimized helpers - `createSuper` now seems to be used, which required 7.9.0: https://github.com/babel/babel/blob/9199565fa08d840c8f1cc86c1b22be119b538f2f/packages/babel-helpers/src/helpers.ts#L624 - this seems to replace the `possibleConstructorReturn` and `getPrototypeOf` helpers - roughly ~6% minified size decrease as a result! - change babel.config.js's caching to include @babel/runtime's version since we would need to rebuild if it changes
1 parent bcf3c3f commit 3db849f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

babel.config.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
const pkgJson = require('./package.json')
2+
3+
const runtimeVersion = pkgJson.dependencies['@babel/runtime']
4+
// eslint-disable-next-line dot-notation -- this conflicts with tsc, possibly due to outdated ESLint
5+
const NODE_ENV = process.env['NODE_ENV']
6+
17
/** @type {import('@babel/core').ConfigFunction} */
28
module.exports = api => {
3-
// eslint-disable-next-line dot-notation -- this conflicts with tsc, possibly due to outdated ESLint
4-
api.cache.using(() => process.env['NODE_ENV']) // cache based on NODE_ENV
9+
api.cache.using(() => NODE_ENV + '_' + runtimeVersion) // cache based on NODE_ENV and runtimeVersion
510

611
// normally use browserslistrc, but for Jest, use current version of Node
712
const isTest = api.env('test')
@@ -24,7 +29,10 @@ module.exports = api => {
2429
],
2530
plugins: [
2631
// used with @rollup/plugin-babel
27-
'@babel/plugin-transform-runtime'
32+
['@babel/plugin-transform-runtime', {
33+
regenerator: false, // not used, and would prefer babel-polyfills over this anyway
34+
version: runtimeVersion // @babel/runtime's version
35+
}]
2836
]
2937
}
3038
}

0 commit comments

Comments
 (0)