Skip to content

Commit

Permalink
Better message
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 29, 2020
1 parent 5dea2ab commit cc1e1c9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
18 changes: 11 additions & 7 deletions packages/babel-helper-create-class-features-plugin/src/features.js
Expand Up @@ -65,8 +65,9 @@ export function enableFeature(file, feature, loose) {
}

let resolvedLoose: void | true | false;
let higherPriorityPluginName: void | string;

for (const [mask] of featuresSameLoose) {
for (const [mask, name] of featuresSameLoose) {
if (!hasFeature(file, mask)) continue;

const loose = isLoose(file, mask);
Expand All @@ -81,6 +82,7 @@ export function enableFeature(file, feature, loose) {
);
} else {
resolvedLoose = loose;
higherPriorityPluginName = name;
}
}

Expand All @@ -89,12 +91,14 @@ export function enableFeature(file, feature, loose) {
if (hasFeature(file, mask) && isLoose(file, mask) !== resolvedLoose) {
setLoose(file, mask, resolvedLoose);
console.warn(
"'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).\n" +
`${name} has been set to \`"loose": ${!resolvedLoose}\` by @babel/preset-env, but it ` +
`will be handled with \`"loose": ${resolvedLoose}\` in order to be compatible with the ` +
"other class features plugins.",
`Though the "loose" option was set to "${!resolvedLoose}" in your @babel/preset-env ` +
`config, it will not be used for ${name} since the "loose" mode option was set to ` +
`"${resolvedLoose}" for ${higherPriorityPluginName}.\nThe "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\n` +
`\t["${name}", { "loose": ${resolvedLoose} }]\n` +
`to the "plugins" section of your Babel config.`,
);
}
}
Expand Down
@@ -1,2 +1,4 @@
'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).
@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.
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.
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
["@babel/plugin-proposal-class-properties", { "loose": true }]
to the "plugins" section of your Babel config.
@@ -1,2 +1,4 @@
'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).
@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.
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.
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
["@babel/plugin-proposal-private-methods", { "loose": true }]
to the "plugins" section of your Babel config.
@@ -1,2 +1,4 @@
'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).
@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.
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.
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
["@babel/plugin-proposal-private-methods", { "loose": false }]
to the "plugins" section of your Babel config.

0 comments on commit cc1e1c9

Please sign in to comment.