forked from babel/babel-polyfills
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: generate shippedProposals from corejs3 compat data
- Loading branch information
Showing
3 changed files
with
32 additions
and
3 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
6 changes: 4 additions & 2 deletions
6
packages/babel-plugin-polyfill-corejs3/src/shipped-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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// @flow | ||
// This file is automatically generated by scripts/build-corejs3-shipped-proposals.js | ||
|
||
export default new Set<string>([ | ||
"esnext.global-this", | ||
"esnext.string.match-all", | ||
"esnext.array.at", | ||
"esnext.object.has-own", | ||
"esnext.typed-array.at", | ||
]); |
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,26 @@ | ||
import compatData from "../packages/babel-plugin-polyfill-corejs3/core-js-compat/data.js"; | ||
import fs from "node:fs"; | ||
|
||
const path = new URL( | ||
"../packages/babel-plugin-polyfill-corejs3/src/shipped-proposals.js", | ||
import.meta.url | ||
); | ||
|
||
const template = features => `// @flow | ||
// This file is automatically generated by scripts/build-corejs3-shipped-proposals.js | ||
export default new Set<string>([ | ||
${features.map(f => ` "${f}",\n`).join("")}]); | ||
`; | ||
|
||
const shippedProposals = []; | ||
|
||
for (const feature in compatData) { | ||
if (!feature.startsWith("esnext.")) continue; | ||
const esName = "es." + feature.slice(7); | ||
if (esName in compatData) continue; | ||
if (Object.keys(compatData[feature]).length === 0) continue; | ||
shippedProposals.push(feature); | ||
} | ||
|
||
fs.writeFileSync(path, template(shippedProposals)); |