Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update preset-env builtin-definitions (#10929)
* chore: build corejs3-proposals.json from core-js-compat * fix: include finished proposals by default * update test fixtures * update test fixtures * chore: rename scripts * fix: add standarized entries for finished proposals * refactor: remove unused finished proposals json * revert test fixtures update * test against corejs 3.6 * fix: move corejs builtin definitions to babel/compat-data
- Loading branch information
Showing
10 changed files
with
59 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/corejs3-shipped-proposals.json"); |
5 changes: 5 additions & 0 deletions
5
packages/babel-compat-data/data/corejs3-shipped-proposals.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
"esnext.global-this", | ||
"esnext.promise.all-settled", | ||
"esnext.string.match-all" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/babel-compat-data/scripts/build-corejs3-proposals.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const data = require("core-js-compat/data.json"); | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const features = Object.keys(data); | ||
|
||
const shippedProposals = features.filter(feature => { | ||
return feature.startsWith("esnext.") && Object.keys(data[feature]).length > 0; | ||
}); | ||
|
||
fs.writeFileSync( | ||
path.join(__dirname, "../data/corejs3-shipped-proposals.json"), | ||
JSON.stringify(shippedProposals, undefined, 2) + "\n" | ||
); | ||
|
||
const finishedProposals = shippedProposals.filter(feature => { | ||
return features.includes(feature.replace("esnext.", "es.")); | ||
}); | ||
|
||
const builtInDefinitionsPath = path.join( | ||
__dirname, | ||
"../../babel-preset-env/src/polyfills/corejs3/built-in-definitions.js" | ||
); | ||
|
||
const builtInDefinitions = fs.readFileSync(builtInDefinitionsPath, "utf-8"); | ||
|
||
for (const feature of finishedProposals) { | ||
const standarizedName = feature.replace("esnext.", "es."); | ||
if (!builtInDefinitions.includes(standarizedName)) { | ||
console.log( | ||
`${feature} is now standarized as ${standarizedName}, please add "${standarizedName}" to "${builtInDefinitionsPath}"` | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
packages/babel-preset-env/src/polyfills/corejs3/shipped-proposals.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"../../../../lib", | ||
{ | ||
"useBuiltIns": "usage", | ||
"corejs": 3, | ||
"corejs": "3.6", | ||
"modules": false | ||
} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters