Skip to content

Commit

Permalink
fix: move corejs builtin definitions to babel/compat-data
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jan 17, 2020
1 parent 1fe2eb7 commit 62bc1d5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/babel-compat-data/corejs3-shipped-proposals.js
@@ -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");
3 changes: 2 additions & 1 deletion packages/babel-compat-data/package.json
Expand Up @@ -12,10 +12,11 @@
"./plugins": "./data/plugins.json",
"./native-modules": "./data/native-modules.json",
"./corejs2-built-ins": "./data/corejs2-built-ins.json",
"./corejs3-shipped-proposals": "./data/corejs3-shipped-proposals",
"./overlapping-plugins": "./data/overlapping-plugins.json"
},
"scripts": {
"build-data": "./scripts/download-compat-table.sh; node ./scripts/build-data.js; node ./scripts/build-modules-support.js; node ./scripts/build-overlapping-plugins.js"
"build-data": "./scripts/download-compat-table.sh; node ./scripts/build-data.js; node ./scripts/build-modules-support.js; node ./scripts/build-overlapping-plugins.js; node ./scripts/build-corejs3-proposals.js"
},
"keywords": [
"babel",
Expand Down
Expand Up @@ -17,16 +17,18 @@ const finishedProposals = shippedProposals.filter(feature => {
return features.includes(feature.replace("esnext.", "es."));
});

const builtInDefinitions = fs.readFileSync(
path.join(__dirname, "../src/polyfills/corejs3/built-in-definitions.js"),
"utf-8"
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 src/polyfills/corejs3/built-in-definitions`
`${feature} is now standarized as ${standarizedName}, please add "${standarizedName}" to "${builtInDefinitionsPath}"`
);
}
}
@@ -1,7 +1,7 @@
// @flow

import corejs3Polyfills from "core-js-compat/data";
import corejs3ShippedProposalsList from "../../../data/corejs3-shipped-proposals.json";
import corejs3ShippedProposalsList from "@babel/compat-data/corejs3-shipped-proposals";
import getModulesListForTargetVersion from "core-js-compat/get-modules-list-for-target-version";
import { filterItems } from "@babel/helper-compilation-targets";
import {
Expand Down

0 comments on commit 62bc1d5

Please sign in to comment.