Skip to content

Commit 19224f9

Browse files
[babel 8] Remove bugfixes option (#17078)
1 parent c079fdd commit 19224f9

195 files changed

Lines changed: 1383 additions & 294 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/babel-preset-env/src/index.ts

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,24 @@ function filterStageFromList(
6060
}, {});
6161
}
6262

63-
const pluginLists = {
64-
withProposals: {
65-
withoutBugfixes: pluginsList,
66-
withBugfixes: Object.assign({}, pluginsList, pluginsBugfixesList),
67-
},
68-
withoutProposals: {
69-
withoutBugfixes: filterStageFromList(pluginsList, proposalPlugins),
70-
withBugfixes: filterStageFromList(
71-
Object.assign({}, pluginsList, pluginsBugfixesList),
72-
proposalPlugins,
73-
),
74-
},
75-
};
63+
const pluginsListWithProposals = Object.assign(
64+
{},
65+
pluginsList,
66+
pluginsBugfixesList,
67+
);
68+
const pluginsListWithuotProposals = filterStageFromList(
69+
pluginsListWithProposals,
70+
proposalPlugins,
71+
);
7672

77-
function getPluginList(proposals: boolean, bugfixes: boolean) {
78-
if (proposals) {
79-
if (bugfixes) return pluginLists.withProposals.withBugfixes;
80-
else return pluginLists.withProposals.withoutBugfixes;
81-
} else {
82-
if (bugfixes) return pluginLists.withoutProposals.withBugfixes;
83-
else return pluginLists.withoutProposals.withoutBugfixes;
84-
}
73+
if (!process.env.BABEL_8_BREAKING) {
74+
// eslint-disable-next-line no-var
75+
var pluginsListNoBugfixesWithProposals = pluginsList;
76+
// eslint-disable-next-line no-var
77+
var pluginsListNoBugfixesWithoutProposals = filterStageFromList(
78+
pluginsList,
79+
proposalPlugins,
80+
);
8581
}
8682

8783
const getPlugin = (pluginName: string) => {
@@ -328,7 +324,6 @@ export default declarePreset((api, opts: Options) => {
328324
}
329325

330326
const {
331-
bugfixes,
332327
configPath,
333328
debug,
334329
exclude: optionsExclude,
@@ -345,7 +340,7 @@ export default declarePreset((api, opts: Options) => {
345340

346341
if (!process.env.BABEL_8_BREAKING) {
347342
// eslint-disable-next-line no-var
348-
var { loose, spec = false } = opts;
343+
var { loose, spec = false, bugfixes = false } = opts;
349344
}
350345

351346
let targets = babelTargets;
@@ -397,7 +392,14 @@ option \`forceAllTransforms: true\` instead.
397392
const include = transformIncludesAndExcludes(optionsInclude);
398393
const exclude = transformIncludesAndExcludes(optionsExclude);
399394

400-
const compatData = getPluginList(shippedProposals, bugfixes);
395+
const compatData =
396+
process.env.BABEL_8_BREAKING || bugfixes
397+
? shippedProposals
398+
? pluginsListWithProposals
399+
: pluginsListWithuotProposals
400+
: shippedProposals
401+
? pluginsListNoBugfixesWithProposals
402+
: pluginsListNoBugfixesWithoutProposals;
401403
const modules =
402404
optionsModules === "auto"
403405
? api.caller(supportsStaticESM)

packages/babel-preset-env/src/normalize-options.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ export function normalizeCoreJSOption(
240240
}
241241

242242
export default function normalizeOptions(opts: Options) {
243+
if (process.env.BABEL_8_BREAKING) {
244+
v.invariant(
245+
!Object.hasOwn(opts, "bugfixes"),
246+
"The 'bugfixes' option has been removed, and now bugfix plugins are" +
247+
" always enabled. Please remove it from your config.",
248+
);
249+
}
250+
243251
v.validateTopLevelOptions(opts, TopLevelOptions);
244252

245253
const useBuiltIns = validateUseBuiltInsOption(opts.useBuiltIns);
@@ -263,14 +271,10 @@ export default function normalizeOptions(opts: Options) {
263271
if (!process.env.BABEL_8_BREAKING) {
264272
v.validateBooleanOption("loose", opts.loose);
265273
v.validateBooleanOption("spec", opts.spec);
274+
v.validateBooleanOption("bugfixes", opts.bugfixes);
266275
}
267276

268277
return {
269-
bugfixes: v.validateBooleanOption(
270-
TopLevelOptions.bugfixes,
271-
opts.bugfixes,
272-
process.env.BABEL_8_BREAKING ? true : false,
273-
),
274278
configPath: v.validateStringOption(
275279
TopLevelOptions.configPath,
276280
opts.configPath,

packages/babel-preset-env/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export const TopLevelOptions = {
2-
bugfixes: "bugfixes",
32
configPath: "configPath",
43
corejs: "corejs",
54
debug: "debug",
@@ -16,6 +15,7 @@ export const TopLevelOptions = {
1615

1716
if (!process.env.BABEL_8_BREAKING) {
1817
Object.assign(TopLevelOptions, {
18+
bugfixes: "bugfixes",
1919
loose: "loose",
2020
spec: "spec",
2121
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class A {
2+
static name = 2;
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"targets": { "chrome": 96 },
3+
"presets": [["env", {
4+
"debug": true,
5+
"exclude": ["bugfix/transform-v8-static-class-fields-redefine-readonly"]
6+
}]]
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class A {
2+
static name = 2;
3+
}

packages/babel-preset-env/test/fixtures/bugfixes/_esmodules-babel-7/input.js renamed to packages/babel-preset-env/test/fixtures/bugfixes-babel-7/_esmodules-babel-7/input.js

File renamed without changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"BABEL_8_BREAKING": false,
3+
"validateLogs": true,
4+
"presets": [
5+
[
6+
"env",
7+
{
8+
"debug": true,
9+
"bugfixes": true,
10+
"targets": {
11+
"esmodules": true
12+
}
13+
}
14+
]
15+
]
16+
}

packages/babel-preset-env/test/fixtures/bugfixes/_esmodules-babel-7/output.js renamed to packages/babel-preset-env/test/fixtures/bugfixes-babel-7/_esmodules-babel-7/output.js

File renamed without changes.

packages/babel-preset-env/test/fixtures/bugfixes/_esmodules-babel-7/stdout.txt renamed to packages/babel-preset-env/test/fixtures/bugfixes-babel-7/_esmodules-babel-7/stdout.txt

File renamed without changes.

0 commit comments

Comments
 (0)