Skip to content

Commit cc1e1c9

Browse files
Better message
1 parent 5dea2ab commit cc1e1c9

File tree

4 files changed

+23
-13
lines changed
  • packages
    • babel-helper-create-class-features-plugin/src
    • babel-preset-env/test/fixtures/loose-class-features-precedence

4 files changed

+23
-13
lines changed

packages/babel-helper-create-class-features-plugin/src/features.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ export function enableFeature(file, feature, loose) {
6565
}
6666

6767
let resolvedLoose: void | true | false;
68+
let higherPriorityPluginName: void | string;
6869

69-
for (const [mask] of featuresSameLoose) {
70+
for (const [mask, name] of featuresSameLoose) {
7071
if (!hasFeature(file, mask)) continue;
7172

7273
const loose = isLoose(file, mask);
@@ -81,6 +82,7 @@ export function enableFeature(file, feature, loose) {
8182
);
8283
} else {
8384
resolvedLoose = loose;
85+
higherPriorityPluginName = name;
8486
}
8587
}
8688

@@ -89,12 +91,14 @@ export function enableFeature(file, feature, loose) {
8991
if (hasFeature(file, mask) && isLoose(file, mask) !== resolvedLoose) {
9092
setLoose(file, mask, resolvedLoose);
9193
console.warn(
92-
"'loose' mode configuration must be the same for @babel/plugin-proposal-class-properties, " +
93-
"@babel/plugin-proposal-private-methods and " +
94-
"@babel/plugin-proposal-private-property-in-object (when they are enabled).\n" +
95-
`${name} has been set to \`"loose": ${!resolvedLoose}\` by @babel/preset-env, but it ` +
96-
`will be handled with \`"loose": ${resolvedLoose}\` in order to be compatible with the ` +
97-
"other class features plugins.",
94+
`Though the "loose" option was set to "${!resolvedLoose}" in your @babel/preset-env ` +
95+
`config, it will not be used for ${name} since the "loose" mode option was set to ` +
96+
`"${resolvedLoose}" for ${higherPriorityPluginName}.\nThe "loose" option must be the ` +
97+
`same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods ` +
98+
`and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can ` +
99+
`silence this warning by explicitly adding\n` +
100+
`\t["${name}", { "loose": ${resolvedLoose} }]\n` +
101+
`to the "plugins" section of your Babel config.`,
98102
);
99103
}
100104
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
'loose' mode configuration must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled).
2-
@babel/plugin-proposal-class-properties has been set to `"loose": false` by @babel/preset-env, but it will be handled with `"loose": true` in order to be compatible with the other class features plugins.
1+
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-class-properties since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-methods.
2+
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
3+
["@babel/plugin-proposal-class-properties", { "loose": true }]
4+
to the "plugins" section of your Babel config.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
'loose' mode configuration must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled).
2-
@babel/plugin-proposal-private-methods has been set to `"loose": false` by @babel/preset-env, but it will be handled with `"loose": true` in order to be compatible with the other class features plugins.
1+
Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "true" for @babel/plugin-proposal-class-properties.
2+
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
3+
["@babel/plugin-proposal-private-methods", { "loose": true }]
4+
to the "plugins" section of your Babel config.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
'loose' mode configuration must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled).
2-
@babel/plugin-proposal-private-methods has been set to `"loose": true` by @babel/preset-env, but it will be handled with `"loose": false` in order to be compatible with the other class features plugins.
1+
Though the "loose" option was set to "true" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-methods since the "loose" mode option was set to "false" for @babel/plugin-proposal-class-properties.
2+
The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding
3+
["@babel/plugin-proposal-private-methods", { "loose": false }]
4+
to the "plugins" section of your Babel config.

0 commit comments

Comments
 (0)