diff --git a/packages/babel-preset-app/package.json b/packages/babel-preset-app/package.json index 44601dac49..fd9f192622 100644 --- a/packages/babel-preset-app/package.json +++ b/packages/babel-preset-app/package.json @@ -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", diff --git a/packages/babel-preset-app/src/index.js b/packages/babel-preset-app/src/index.js index 6abbe06738..3a1f7d3406 100644 --- a/packages/babel-preset-app/src/index.js +++ b/packages/babel-preset-app/src/index.js @@ -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