-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include preset modules #11083
Include preset modules #11083
Changes from all commits
22f62b3
07c2aaf
02e032d
328101d
7265841
4ab53d2
f4f2b28
d970c7a
cd06d59
aab3282
32f29c2
e71dee6
6261317
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
declare module "@babel/preset-modules/lib/plugins/transform-async-arrows-in-class" { | ||
declare module.exports: Function; | ||
} | ||
declare module "@babel/preset-modules/lib/plugins/transform-edge-default-parameters" { | ||
declare module.exports: Function; | ||
} | ||
declare module "@babel/preset-modules/lib/plugins/transform-edge-function-name" { | ||
declare module.exports: Function; | ||
} | ||
declare module "@babel/preset-modules/lib/plugins/transform-tagged-template-caching" { | ||
declare module.exports: Function; | ||
} | ||
declare module "@babel/preset-modules/lib/plugins/transform-safari-block-shadowing" { | ||
declare module.exports: Function; | ||
} | ||
declare module "@babel/preset-modules/lib/plugins/transform-safari-for-shadowing" { | ||
declare module.exports: Function; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
{ | ||
"transform-regenerator": [] | ||
} | ||
"transform-async-to-generator": [ | ||
"bugfix/transform-async-arrows-in-class" | ||
], | ||
"transform-parameters": [ | ||
"bugfix/transform-edge-default-parameters" | ||
], | ||
"transform-function-name": [ | ||
"bugfix/transform-edge-function-name" | ||
], | ||
"transform-block-scoping": [ | ||
"bugfix/transform-safari-block-shadowing", | ||
"bugfix/transform-safari-for-shadowing" | ||
], | ||
"transform-template-literals": [ | ||
"bugfix/transform-tagged-template-caching" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nicolo-ribaudo - meta-comment, more on the data format itself: do you think it might be easier to maintain this file if the data only specified which versions were actually affected by the bugfix plugins? For example, the edge function name plugin could just be listed as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This data is generated by the same script which generated the old data, so it's easier to generate all the targets 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah! gotcha. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it could be interesting to create a rendered version based on the data on our website or something? Or just showcasing this in general in a more readable manner? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something like compat-table but with plugin names rather than ECMAScript features? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, then you could generate what @developit was saying allow about seeing the diff's or what was actually affected? Maybe we should add a simple readme to explain each json file |
||
"transform-async-to-generator": { | ||
"chrome": "55", | ||
"edge": "15", | ||
"firefox": "52", | ||
"safari": "10.1", | ||
"node": "7.6", | ||
"ios": "10.3", | ||
"samsung": "6", | ||
"opera": "42", | ||
"electron": "1.6" | ||
}, | ||
"bugfix/transform-async-arrows-in-class": { | ||
"chrome": "55", | ||
"edge": "15", | ||
"firefox": "52", | ||
"safari": "11", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Edit: I keep thinking this list is "versions that are fixed by X", but it's actually "oldest version where this plugin is not needed", right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
👍 |
||
"node": "7.6", | ||
"ios": "11", | ||
"samsung": "6", | ||
"opera": "42", | ||
"electron": "1.6" | ||
}, | ||
"transform-parameters": { | ||
"chrome": "49", | ||
"edge": "15", | ||
"firefox": "53", | ||
"safari": "10", | ||
"node": "6", | ||
"ios": "10", | ||
"samsung": "5", | ||
"opera": "36", | ||
"electron": "1" | ||
}, | ||
"bugfix/transform-edge-default-parameters": { | ||
"chrome": "49", | ||
"edge": "18", | ||
"firefox": "52", | ||
"safari": "10", | ||
"node": "6", | ||
"ios": "10", | ||
"samsung": "5", | ||
"opera": "36", | ||
"electron": "1" | ||
}, | ||
"transform-function-name": { | ||
"chrome": "51", | ||
"edge": "14", | ||
"firefox": "53", | ||
"safari": "10", | ||
"node": "6.5", | ||
"ios": "10", | ||
"samsung": "5", | ||
"opera": "38", | ||
"electron": "1.2" | ||
}, | ||
"bugfix/transform-edge-function-name": { | ||
"chrome": "51", | ||
"edge": "79", | ||
"firefox": "53", | ||
"safari": "10", | ||
"node": "6.5", | ||
"ios": "10", | ||
"samsung": "5", | ||
"opera": "38", | ||
"electron": "1.2" | ||
}, | ||
"transform-block-scoping": { | ||
"chrome": "49", | ||
"edge": "14", | ||
"firefox": "51", | ||
"safari": "10", | ||
"node": "6", | ||
"ios": "10", | ||
"samsung": "5", | ||
"opera": "36", | ||
"electron": "1" | ||
}, | ||
"bugfix/transform-safari-block-shadowing": { | ||
"chrome": "49", | ||
"edge": "12", | ||
"firefox": "44", | ||
"safari": "11", | ||
"node": "6", | ||
"ie": "11", | ||
"ios": "11", | ||
"samsung": "5", | ||
"opera": "36", | ||
"electron": "1" | ||
}, | ||
"bugfix/transform-safari-for-shadowing": { | ||
"chrome": "49", | ||
"edge": "12", | ||
"firefox": "4", | ||
"safari": "11", | ||
"node": "6", | ||
"ie": "11", | ||
"ios": "11", | ||
"samsung": "5", | ||
"opera": "36", | ||
"electron": "1" | ||
}, | ||
"transform-template-literals": { | ||
"chrome": "41", | ||
"edge": "13", | ||
"firefox": "34", | ||
"safari": "9", | ||
"node": "4", | ||
"ios": "9", | ||
"samsung": "3.4", | ||
"opera": "28", | ||
"electron": "0.24" | ||
}, | ||
"bugfix/transform-tagged-template-caching": { | ||
"chrome": "41", | ||
"edge": "12", | ||
"firefox": "34", | ||
"safari": "13", | ||
"node": "4", | ||
"ios": "13", | ||
"samsung": "3.4", | ||
"opera": "28", | ||
"electron": "0.24" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Node < 13.3 doesn't support export maps in package.json. | ||
// Use this proxy file as a fallback. | ||
|
||
module.exports = require("./data/plugin-bugfixes.json"); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"use strict"; | ||
|
||
// NOTE: This script must be run _after_ build-data.js | ||
|
||
const path = require("path"); | ||
|
||
const { | ||
getLowestImplementedVersion, | ||
environments, | ||
addOperaAndElectron, | ||
writeFile, | ||
} = require("./utils-build-data"); | ||
|
||
const data = require("./data/plugin-bugfixes"); | ||
const pluginFeatures = require("./data/plugin-features"); | ||
|
||
const generatedTargets = {}; | ||
const overlappingPlugins = {}; | ||
|
||
const allReplacedFeatures = {}; | ||
|
||
const has = Function.call.bind(Object.hasOwnProperty); | ||
|
||
for (const [plugin, { replaces, features }] of Object.entries(data)) { | ||
if (!has(overlappingPlugins, replaces)) { | ||
overlappingPlugins[replaces] = []; | ||
generatedTargets[replaces] = {}; | ||
allReplacedFeatures[replaces] = []; | ||
} | ||
generatedTargets[plugin] = {}; | ||
|
||
allReplacedFeatures[replaces].push(...features); | ||
|
||
overlappingPlugins[replaces].push(plugin); | ||
|
||
for (const env of environments) { | ||
const supportedWithBugfix = getLowestImplementedVersion({ features }, env); | ||
if (supportedWithBugfix) { | ||
generatedTargets[plugin][env] = supportedWithBugfix; | ||
} | ||
} | ||
} | ||
|
||
for (const [replaced, features] of Object.entries(allReplacedFeatures)) { | ||
let replacedFeatures = pluginFeatures[replaced]; | ||
if (!Array.isArray(replacedFeatures)) { | ||
replacedFeatures = replacedFeatures.features; | ||
} | ||
|
||
for (const env of environments) { | ||
const stillNotSupported = getLowestImplementedVersion( | ||
{ features: replacedFeatures }, | ||
env, | ||
name => features.some(feat => name.includes(feat)) | ||
); | ||
|
||
if (stillNotSupported) { | ||
generatedTargets[replaced][env] = stillNotSupported; | ||
} | ||
} | ||
} | ||
|
||
for (const plugin of Object.values(generatedTargets)) { | ||
addOperaAndElectron(plugin); | ||
} | ||
|
||
for (const [filename, data] of [ | ||
["plugin-bugfixes", generatedTargets], | ||
["overlapping-plugins", overlappingPlugins], | ||
]) { | ||
const dataPath = path.join(__dirname, `../data/${filename}.json`); | ||
|
||
if (!writeFile(data, dataPath, filename)) { | ||
process.exitCode = 1; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
transform-regenerator
be here too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally yes. We did it in the past,but had to revert it because regenerator doesn't support async functions with polyfilled promises.
I'd like to revisit it in Babel 8 somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. At least when bugfixes is enabled though, regenerator will never be included, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only included when targeting browsers not supporting generators (we don't use it for async functions).
It's unrelated to
bugfixes
: it isn't included because of theesmodules
option.