Debian Codegraph @

packages/babel-compat-data/scripts/build-corejs3-proposals.js

raw
1 const data = require("core-js-compat/data.json");
2 const fs = require("fs");
3 const path = require("path");
4
5 const features = Object.keys(data);
6
7 const shippedProposals = features.filter(feature => {
8 return feature.startsWith("esnext.") && Object.keys(data[feature]).length > 0;
9 });
10
11 fs.writeFileSync(
12 path.join(__dirname, "../data/corejs3-shipped-proposals.json"),
13 JSON.stringify(shippedProposals, undefined, 2) + "\n"
14 );
15
16 const finishedProposals = shippedProposals.filter(feature => {
17 return features.includes(feature.replace("esnext.", "es."));
18 });
19
20 const builtInDefinitionsPath = path.join(
21 __dirname,
22 "../../babel-preset-env/src/polyfills/corejs3/built-in-definitions.js"
23 );
24
25 const builtInDefinitions = fs.readFileSync(builtInDefinitionsPath, "utf-8");
26
27 for (const feature of finishedProposals) {
28 const standardizedName = feature.replace("esnext.", "es.");
29 if (!builtInDefinitions.includes(standardizedName)) {
30 console.log(
31 `${feature} is now standarized as ${standardizedName}, please add "${standardizedName}" to "${builtInDefinitionsPath}"`
32 );
33 }
34 }