Skip to content

Commit

Permalink
[babel 8] Remove bugfixes option
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jan 22, 2025
1 parent c079fdd commit e432abf
Show file tree
Hide file tree
Showing 192 changed files with 1,370 additions and 294 deletions.
50 changes: 26 additions & 24 deletions packages/babel-preset-env/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,24 @@ function filterStageFromList(
}, {});
}

const pluginLists = {
withProposals: {
withoutBugfixes: pluginsList,
withBugfixes: Object.assign({}, pluginsList, pluginsBugfixesList),
},
withoutProposals: {
withoutBugfixes: filterStageFromList(pluginsList, proposalPlugins),
withBugfixes: filterStageFromList(
Object.assign({}, pluginsList, pluginsBugfixesList),
proposalPlugins,
),
},
};
const pluginsListWithProposals = Object.assign(
{},
pluginsList,
pluginsBugfixesList,
);
const pluginsListWithuotProposals = filterStageFromList(
pluginsListWithProposals,
proposalPlugins,
);

function getPluginList(proposals: boolean, bugfixes: boolean) {
if (proposals) {
if (bugfixes) return pluginLists.withProposals.withBugfixes;
else return pluginLists.withProposals.withoutBugfixes;
} else {
if (bugfixes) return pluginLists.withoutProposals.withBugfixes;
else return pluginLists.withoutProposals.withoutBugfixes;
}
if (!process.env.BABEL_8_BREAKING) {
// eslint-disable-next-line no-var
var pluginsListNoBugfixesWithProposals = pluginsList;
// eslint-disable-next-line no-var
var pluginsListNoBugfixesWithoutProposals = filterStageFromList(
pluginsList,
proposalPlugins,
);
}

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

const {
bugfixes,
configPath,
debug,
exclude: optionsExclude,
Expand All @@ -345,7 +340,7 @@ export default declarePreset((api, opts: Options) => {

if (!process.env.BABEL_8_BREAKING) {
// eslint-disable-next-line no-var
var { loose, spec = false } = opts;
var { loose, spec = false, bugfixes = false } = opts;
}

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

const compatData = getPluginList(shippedProposals, bugfixes);
const compatData =
process.env.BABEL_8_BREAKING || bugfixes
? shippedProposals
? pluginsListWithProposals
: pluginsListWithuotProposals
: shippedProposals
? pluginsListNoBugfixesWithProposals
: pluginsListNoBugfixesWithoutProposals;
const modules =
optionsModules === "auto"
? api.caller(supportsStaticESM)
Expand Down
14 changes: 9 additions & 5 deletions packages/babel-preset-env/src/normalize-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ export function normalizeCoreJSOption(
}

export default function normalizeOptions(opts: Options) {
if (process.env.BABEL_8_BREAKING) {
v.invariant(
!Object.hasOwn(opts, "bugfixes"),
"The 'bugfixes' option has been removed, and now bugfix plugins are" +
" always enabled. Please remove it from your config.",
);
}

v.validateTopLevelOptions(opts, TopLevelOptions);

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

return {
bugfixes: v.validateBooleanOption(
TopLevelOptions.bugfixes,
opts.bugfixes,
process.env.BABEL_8_BREAKING ? true : false,
),
configPath: v.validateStringOption(
TopLevelOptions.configPath,
opts.configPath,
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-env/src/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const TopLevelOptions = {
bugfixes: "bugfixes",
configPath: "configPath",
corejs: "corejs",
debug: "debug",
Expand All @@ -16,6 +15,7 @@ export const TopLevelOptions = {

if (!process.env.BABEL_8_BREAKING) {
Object.assign(TopLevelOptions, {
bugfixes: "bugfixes",
loose: "loose",
spec: "spec",
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"esmodules": true
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": false,
"targets": {
"esmodules": true
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": false,
"targets": {
"esmodules": true
}
}
]
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ Using plugins:
transform-export-namespace-from { android < 72, chrome < 72, edge < 79, firefox < 80, ios < 14.5, opera < 60, safari < 14.1, samsung < 11.0 }
transform-modules-commonjs
transform-dynamic-import
syntax-top-level-await
syntax-import-meta

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"esmodules": true
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@babel/preset-env: `DEBUG` option

Using targets:
{
"android": "61",
"chrome": "61",
"edge": "16",
"firefox": "60",
"ios": "10.3",
"node": "13.2",
"opera": "48",
"opera_mobile": "80",
"safari": "10.1",
"samsung": "8.2"
}

Using modules transform: auto

Using plugins:
transform-duplicate-named-capturing-groups-regex { android, chrome < 126, edge < 126, firefox < 129, ios < 17.4, node < 23, opera < 112, opera_mobile, safari < 17.4, samsung }
transform-regexp-modifiers { android, chrome < 125, edge < 125, firefox < 132, ios, node < 23, opera < 111, opera_mobile, safari, samsung }
transform-unicode-sets-regex { android, chrome < 112, edge < 112, firefox < 116, ios < 17, node < 20, opera < 98, safari < 17, samsung }
transform-class-static-block { android, chrome < 94, edge < 94, firefox < 93, ios < 16.4, node < 16.11, opera < 80, safari < 16.4, samsung < 17 }
transform-private-property-in-object { android, chrome < 91, edge < 91, firefox < 90, ios < 15, node < 16.9, opera < 77, safari < 15, samsung < 16 }
transform-class-properties { android, chrome < 74, edge < 79, firefox < 90, ios < 14.5, opera < 62, safari < 14.1, samsung < 11 }
transform-private-methods { android, chrome < 84, edge < 84, firefox < 90, ios < 15, node < 14.6, opera < 70, safari < 15, samsung < 14 }
transform-numeric-separator { android, chrome < 75, edge < 79, firefox < 70, ios < 13, opera < 62, safari < 13, samsung < 11 }
transform-logical-assignment-operators { android, chrome < 85, edge < 85, firefox < 79, ios < 14, node < 15, opera < 71, safari < 14, samsung < 14 }
transform-nullish-coalescing-operator { android, chrome < 80, edge < 80, firefox < 72, ios < 13.4, node < 14, opera < 67, safari < 13.1, samsung < 13 }
transform-optional-chaining { android, chrome < 80, edge < 80, firefox < 74, ios < 13.4, node < 14, opera < 67, safari < 13.1, samsung < 13 }
transform-json-strings { android, chrome < 66, edge < 79, firefox < 62, ios < 12, opera < 53, safari < 12, samsung < 9 }
transform-optional-catch-binding { android, chrome < 66, edge < 79, ios < 11.3, opera < 53, safari < 11.1, samsung < 9 }
transform-async-generator-functions { android, chrome < 63, edge < 79, ios < 12, opera < 50, safari < 12 }
transform-object-rest-spread { edge < 79, ios < 11.3, safari < 11.1 }
transform-dotall-regex { android, chrome < 62, edge < 79, firefox < 78, ios < 11.3, opera < 49, safari < 11.1 }
transform-unicode-property-regex { android, chrome < 64, edge < 79, firefox < 78, ios < 11.3, opera < 51, safari < 11.1, samsung < 9 }
transform-named-capturing-groups-regex { android, chrome < 64, edge < 79, firefox < 78, ios < 11.3, opera < 51, safari < 11.1, samsung < 9 }
transform-unicode-regex { ios < 12, safari < 12 }
transform-export-namespace-from { android < 72, chrome < 72, edge < 79, firefox < 80, ios < 14.5, opera < 60, safari < 14.1, samsung < 11.0 }
bugfix/transform-async-arrows-in-class { ios < 11, safari < 11 }
bugfix/transform-edge-default-parameters { edge < 18 }
bugfix/transform-edge-function-name { edge < 79 }
bugfix/transform-safari-block-shadowing { ios < 11, safari < 11 }
bugfix/transform-safari-for-shadowing { ios < 11, safari < 11 }
bugfix/transform-safari-id-destructuring-collision-in-function-expression { ios < 16.3, safari < 16.3 }
bugfix/transform-tagged-template-caching { ios < 13, safari < 13 }
transform-modules-commonjs
transform-dynamic-import
syntax-top-level-await
syntax-import-meta

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"chrome": "40"
},
"exclude": [
"transform-destructuring",
"transform-arrow-functions"
]
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"chrome": "70"
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"edge": "14"
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"edge": "15"
},
"exclude": [
"transform-destructuring",
"transform-arrow-functions"
]
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": false,
"targets": {
"edge": "17"
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"edge": "17"
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"BABEL_8_BREAKING": false,
"validateLogs": true,
"presets": [
[
"env",
{
"debug": true,
"bugfixes": true,
"targets": {
"edge": "18"
}
}
]
]
}
Loading

0 comments on commit e432abf

Please sign in to comment.