diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-05-14 14:05:49 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-05-14 14:05:49 +0800 |
| commit | 06823fbf1c2e763a5bf76c3990ca98fbbcd98691 (patch) | |
| tree | 4280bece3888d12a022093bf1a9cd1b049393602 /node_modules/@babel/helper-create-class-features-plugin/lib/features.js | |
| parent | 1368909b3cd552dbb0d12d5863c597f5be46177d (diff) | |
updated node_modules
Diffstat (limited to 'node_modules/@babel/helper-create-class-features-plugin/lib/features.js')
| -rw-r--r-- | node_modules/@babel/helper-create-class-features-plugin/lib/features.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/node_modules/@babel/helper-create-class-features-plugin/lib/features.js b/node_modules/@babel/helper-create-class-features-plugin/lib/features.js index a4ad9ff8..5cc919c6 100644 --- a/node_modules/@babel/helper-create-class-features-plugin/lib/features.js +++ b/node_modules/@babel/helper-create-class-features-plugin/lib/features.js @@ -47,7 +47,7 @@ function enableFeature(file, feature, loose) { } const loose = isLoose(file, mask); if (resolvedLoose === !loose) { - throw new Error("'loose' mode configuration must be the same for @babel/plugin-transform-class-properties, " + "@babel/plugin-transform-private-methods and " + "@babel/plugin-transform-private-property-in-object (when they are enabled)."); + throw new Error("'loose' mode configuration must be the same for @babel/plugin-transform-class-properties, " + "@babel/plugin-transform-private-methods and " + "@babel/plugin-transform-private-property-in-object (when they are enabled)." + "\n\n" + getBabelShowConfigForHint(file)); } else { resolvedLoose = loose; { @@ -59,11 +59,26 @@ function enableFeature(file, feature, loose) { for (const [mask, name] of featuresSameLoose) { if (hasFeature(file, mask) && isLoose(file, mask) !== resolvedLoose) { setLoose(file, mask, resolvedLoose); - console.warn(`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-transform-class-properties, @babel/plugin-transform-private-methods ` + `and @babel/plugin-transform-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.`); + console.warn(`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-transform-class-properties, @babel/plugin-transform-private-methods ` + `and @babel/plugin-transform-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.` + "\n\n" + getBabelShowConfigForHint(file)); } } } } +function getBabelShowConfigForHint(file) { + let { + filename + } = file.opts; + if (!filename || filename === "unknown") { + filename = "[name of the input file]"; + } + return `\ +If you already set the same 'loose' mode for these plugins in your config, it's possible that they \ +are enabled multiple times with different options. +You can re-run Babel with the BABEL_SHOW_CONFIG_FOR environment variable to show the loaded \ +configuration: +\tnpx cross-env BABEL_SHOW_CONFIG_FOR=${filename} <your build command> +See https://babeljs.io/docs/configuration#print-effective-configs for more info.`; +} function hasFeature(file, feature) { return !!(file.get(featuresKey) & feature); } |
