fix(babel): loose option for babel class-properties and private-methods (#9232)

This commit is contained in:
Xin Du (Clark) 2021-05-03 13:06:27 +01:00
parent 65e62b96a3
commit 1e249cc290
2 changed files with 13 additions and 2 deletions

View File

@ -18,6 +18,7 @@
"@babel/plugin-proposal-decorators": "^7.13.15",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.13.8",
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
"@babel/plugin-proposal-private-methods": "^7.13.0",
"@babel/plugin-transform-runtime": "^7.13.15",
"@babel/preset-env": "^7.14.0",
"@babel/runtime": "^7.14.0",

View File

@ -135,7 +135,15 @@ module.exports = (api, options = {}) => {
ignoreBrowserslistConfig,
configPath,
include,
exclude: polyfills.concat(exclude || []),
exclude: [
...exclude || [],
...polyfills,
// Although preset-env includes class-properties
// but webpack 4 doesn't support the syntax when target supports and babel transpilation is skipped
// https://github.com/webpack/webpack/issues/9708
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-private-methods'
],
shippedProposals,
forceAllTransforms
}
@ -151,7 +159,9 @@ module.exports = (api, options = {}) => {
decoratorsBeforeExport,
legacy: decoratorsLegacy !== false
}],
[require('@babel/plugin-proposal-class-properties'), { loose: true }]
// class-properties and private-methods need same loose value
[require('@babel/plugin-proposal-class-properties'), { loose: true }],
[require('@babel/plugin-proposal-private-methods'), { loose: true }]
)
// Transform runtime, but only for helpers