Skip to content

Commit

Permalink
fix: print warning messages to stderr (#12626)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jan 14, 2021
1 parent bd4590e commit 6e9a174
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 66 deletions.
15 changes: 6 additions & 9 deletions packages/babel-helper-compilation-targets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,14 @@ function outputDecimalWarning(
return;
}

console.log("Warning, the following targets are using a decimal version:");
console.log("");
console.warn("Warning, the following targets are using a decimal version:\n");
decimalTargets.forEach(({ target, value }) =>
console.log(` ${target}: ${value}`),
console.warn(` ${target}: ${value}`),
);
console.log("");
console.log(
"We recommend using a string for minor/patch versions to avoid numbers like 6.10",
);
console.log("getting parsed as 6.1, which can lead to unexpected behavior.");
console.log("");
console.warn(`
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.
`);
}

function semverifyTarget(target, value) {
Expand Down
21 changes: 8 additions & 13 deletions packages/babel-preset-env/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,23 +251,18 @@ export default declare((api, opts) => {
hasUglifyTarget = true;
delete optionsTargets.uglify;

console.log("");
console.log("The uglify target has been deprecated. Set the top level");
console.log("option `forceAllTransforms: true` instead.");
console.log("");
console.warn(`
The uglify target has been deprecated. Set the top level
option \`forceAllTransforms: true\` instead.
`);
}
}

if (optionsTargets?.esmodules && optionsTargets.browsers) {
console.log("");
console.log(
"@babel/preset-env: esmodules and browsers targets have been specified together.",
);
console.log(
// $FlowIgnore
`\`browsers\` target, \`${optionsTargets.browsers}\` will be ignored.`,
);
console.log("");
console.warn(`
@babel/preset-env: esmodules and browsers targets have been specified together.
\`browsers\` target, \`${optionsTargets.browsers.toString()}\` will be ignored.
`);
}

const targets = getTargets(
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-env/src/normalize-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function normalizeCoreJSOption(
const version = rawVersion ? coerce(String(rawVersion)) : false;

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",
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`
Original file line number Diff line number Diff line change
@@ -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

Using targets:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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

Using targets:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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

Using targets:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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

Using targets:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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

Using targets:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ You should also be sure that the version you pass to the `corejs` option matches
yarn add core-js@2 yarn add core-js@3

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.
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
The uglify target has been deprecated. Set the top level
option `forceAllTransforms: true` instead.

@babel/preset-env: `DEBUG` option

Using targets:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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

Using targets:
Expand Down

0 comments on commit 6e9a174

Please sign in to comment.