Skip to content

Commit

Permalink
[babel 8] Remove uglify target support in preset-env (#12594)
Browse files Browse the repository at this point in the history
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
  • Loading branch information
nicolo-ribaudo and JLHwung committed Jan 8, 2021
1 parent 6e70dea commit 606c91c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
29 changes: 19 additions & 10 deletions packages/babel-preset-env/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,20 @@ export default declare((api, opts) => {
corejs: { version: corejs, proposals },
browserslistEnv,
} = normalizeOptions(opts);
// TODO: remove this in next major
let hasUglifyTarget = false;

if (optionsTargets?.uglify) {
hasUglifyTarget = true;
delete optionsTargets.uglify;
if (!process.env.BABEL_8_BREAKING) {
// eslint-disable-next-line no-var
var hasUglifyTarget = false;

console.log("");
console.log("The uglify target has been deprecated. Set the top level");
console.log("option `forceAllTransforms: true` instead.");
console.log("");
if (optionsTargets?.uglify) {
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("");
}
}

if (optionsTargets?.esmodules && optionsTargets.browsers) {
Expand All @@ -275,7 +278,13 @@ export default declare((api, opts) => {
const include = transformIncludesAndExcludes(optionsInclude);
const exclude = transformIncludesAndExcludes(optionsExclude);

const transformTargets = forceAllTransforms || hasUglifyTarget ? {} : targets;
const transformTargets = (
process.env.BABEL_8_BREAKING
? forceAllTransforms
: forceAllTransforms || hasUglifyTarget
)
? {}
: targets;

const compatData = getPluginList(shippedProposals, bugfixes);
const shouldSkipExportNamespaceFrom =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"ignoreOutput": true,
"presets": [
Expand Down

0 comments on commit 606c91c

Please sign in to comment.