fix: print warning messages to stderr (#12626)

This commit is contained in:
Huáng Jùnliàng 2021-01-14 08:45:48 -05:00 committed by GitHub
parent bd4590e546
commit 6e9a174e7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 52 additions and 66 deletions

View File

@ -103,17 +103,14 @@ function outputDecimalWarning(
return; return;
} }
console.log("Warning, the following targets are using a decimal version:"); console.warn("Warning, the following targets are using a decimal version:\n");
console.log("");
decimalTargets.forEach(({ target, value }) => decimalTargets.forEach(({ target, value }) =>
console.log(` ${target}: ${value}`), console.warn(` ${target}: ${value}`),
); );
console.log(""); console.warn(`
console.log( We recommend using a string for minor/patch versions to avoid numbers like 6.10
"We recommend using a string for minor/patch versions to avoid numbers like 6.10", getting parsed as 6.1, which can lead to unexpected behavior.
); `);
console.log("getting parsed as 6.1, which can lead to unexpected behavior.");
console.log("");
} }
function semverifyTarget(target, value) { function semverifyTarget(target, value) {

View File

@ -251,23 +251,18 @@ export default declare((api, opts) => {
hasUglifyTarget = true; hasUglifyTarget = true;
delete optionsTargets.uglify; delete optionsTargets.uglify;
console.log(""); console.warn(`
console.log("The uglify target has been deprecated. Set the top level"); The uglify target has been deprecated. Set the top level
console.log("option `forceAllTransforms: true` instead."); option \`forceAllTransforms: true\` instead.
console.log(""); `);
} }
} }
if (optionsTargets?.esmodules && optionsTargets.browsers) { if (optionsTargets?.esmodules && optionsTargets.browsers) {
console.log(""); console.warn(`
console.log( @babel/preset-env: esmodules and browsers targets have been specified together.
"@babel/preset-env: esmodules and browsers targets have been specified together.", \`browsers\` target, \`${optionsTargets.browsers.toString()}\` will be ignored.
); `);
console.log(
// $FlowIgnore
`\`browsers\` target, \`${optionsTargets.browsers}\` will be ignored.`,
);
console.log("");
} }
const targets = getTargets( const targets = getTargets(

View File

@ -184,7 +184,7 @@ export function normalizeCoreJSOption(
const version = rawVersion ? coerce(String(rawVersion)) : false; const version = rawVersion ? coerce(String(rawVersion)) : false;
if (!useBuiltIns && version) { if (!useBuiltIns && version) {
console.log( console.warn(
"\nWARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`\n", "\nWARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`\n",
); );
} }

View File

@ -0,0 +1 @@
WARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`

View File

@ -1,5 +1,3 @@
WARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`
@babel/preset-env: `DEBUG` option @babel/preset-env: `DEBUG` option
Using targets: Using targets:

View File

@ -0,0 +1,6 @@
Warning, the following targets are using a decimal version:
electron: 0.36
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.

View File

@ -1,10 +1,3 @@
Warning, the following targets are using a decimal version:
electron: 0.36
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.
@babel/preset-env: `DEBUG` option @babel/preset-env: `DEBUG` option
Using targets: Using targets:

View File

@ -0,0 +1,7 @@
Warning, the following targets are using a decimal version:
electron: 0.36
node: 6.1
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.

View File

@ -1,11 +1,3 @@
Warning, the following targets are using a decimal version:
electron: 0.36
node: 6.1
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.
@babel/preset-env: `DEBUG` option @babel/preset-env: `DEBUG` option
Using targets: Using targets:

View File

@ -0,0 +1,6 @@
Warning, the following targets are using a decimal version:
electron: 0.36
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.

View File

@ -1,10 +1,3 @@
Warning, the following targets are using a decimal version:
electron: 0.36
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.
@babel/preset-env: `DEBUG` option @babel/preset-env: `DEBUG` option
Using targets: Using targets:

View File

@ -0,0 +1,7 @@
Warning, the following targets are using a decimal version:
electron: 0.36
node: 6.1
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.

View File

@ -1,11 +1,3 @@
Warning, the following targets are using a decimal version:
electron: 0.36
node: 6.1
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.
@babel/preset-env: `DEBUG` option @babel/preset-env: `DEBUG` option
Using targets: Using targets:

View File

@ -7,3 +7,6 @@ You should also be sure that the version you pass to the `corejs` option matches
More info about useBuiltIns: https://babeljs.io/docs/en/babel-preset-env#usebuiltins More info about useBuiltIns: https://babeljs.io/docs/en/babel-preset-env#usebuiltins
More info about core-js: https://babeljs.io/docs/en/babel-preset-env#corejs More info about core-js: https://babeljs.io/docs/en/babel-preset-env#corejs
The uglify target has been deprecated. Set the top level
option `forceAllTransforms: true` instead.

View File

@ -1,6 +1,3 @@
The uglify target has been deprecated. Set the top level
option `forceAllTransforms: true` instead.
@babel/preset-env: `DEBUG` option @babel/preset-env: `DEBUG` option
Using targets: Using targets:

View File

@ -0,0 +1,6 @@
Warning, the following targets are using a decimal version:
node: 7.4
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.

View File

@ -1,10 +1,3 @@
Warning, the following targets are using a decimal version:
node: 7.4
We recommend using a string for minor/patch versions to avoid numbers like 6.10
getting parsed as 6.1, which can lead to unexpected behavior.
@babel/preset-env: `DEBUG` option @babel/preset-env: `DEBUG` option
Using targets: Using targets: