Skip to content

Commit

Permalink
fix(web): syncs loose option between @babel/preset-env and @babel/p…
Browse files Browse the repository at this point in the history
…lugin-proposal-class-properties (#6715)

If `loose` is set to `true` for `@babel/plugin-proposal-class-properties`, the same must be true for
`@babel/preset-env`.

ISSUES CLOSED: #6683
  • Loading branch information
rmarganti authored Aug 19, 2021
1 parent b320624 commit 7496483
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/web/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ module.exports = function (api: any, options: NxReactBabelPresetOptions = {}) {
(caller) => caller?.emitDecoratorMetadata ?? true
);

// Determine settings for `@babel/plugin-proposal-class-properties`,
// so that we can sync the `loose` option with `@babel/preset-env`.
const classProperties = options.classProperties ?? { loose: true };

return {
presets: [
// Support module/nomodule pattern.
Expand All @@ -48,6 +52,8 @@ module.exports = function (api: any, options: NxReactBabelPresetOptions = {}) {
bugfixes: true,
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
// This must match the setting for `@babel/plugin-proposal-class-properties`
loose: classProperties.loose,
},
],
require.resolve('@babel/preset-typescript'),
Expand Down Expand Up @@ -78,7 +84,7 @@ module.exports = function (api: any, options: NxReactBabelPresetOptions = {}) {
],
[
require.resolve('@babel/plugin-proposal-class-properties'),
options.classProperties ?? { loose: true },
classProperties,
],
].filter(Boolean),
overrides: [
Expand Down

0 comments on commit 7496483

Please sign in to comment.