| 1 |
"use strict"; |
| 2 |
|
| 3 |
const path = require("path"); |
| 4 |
const compatData = require("@mdn/browser-compat-data").javascript; |
| 5 |
const { process: processData } = require("./build-modules-support"); |
| 6 |
const { |
| 7 |
generateData, |
| 8 |
environments, |
| 9 |
writeFile, |
| 10 |
defineLegacyPluginAliases, |
| 11 |
} = require("./utils-build-data"); |
| 12 |
|
| 13 |
if (process.cwd().endsWith("scripts")) { |
| 14 |
throw new Error("Please run this script from the root of the package"); |
| 15 |
} |
| 16 |
|
| 17 |
for (const target of ["plugin", "corejs2-built-in"]) { |
| 18 |
// We ignore 'overlapping' here, because it's already generated by |
| 19 |
// built-bugfixes-targets.js which has a complete view over all the |
| 20 |
// plugins that we have data for. |
| 21 |
let { data: newData } = generateData( |
| 22 |
environments, |
| 23 |
require(`./data/${target}-features`) |
| 24 |
); |
| 25 |
if (target === "plugin") { |
| 26 |
// add export-namespace-from from @mdn/browser-compat-data |
| 27 |
const exportNamespaceFromCompatData = processData( |
| 28 |
compatData.statements.export.namespace |
| 29 |
); |
| 30 |
// the node.js compat data is 12.0, the first node version ships `export *` behind a flag |
| 31 |
// here we overwrite to 13.2 which is the first unflagged version |
| 32 |
exportNamespaceFromCompatData.node = "13.2"; |
| 33 |
newData["transform-export-namespace-from"] = exportNamespaceFromCompatData; |
| 34 |
|
| 35 |
// Add proposal-* aliases for backward compatibility. |
| 36 |
// TODO(Babel 7): This won't be needed anymore. |
| 37 |
newData = defineLegacyPluginAliases(newData); |
| 38 |
} |
| 39 |
const dataPath = path.join(__dirname, `../data/${target}s.json`); |
| 40 |
|
| 41 |
if (!writeFile(newData, dataPath, target)) { |
| 42 |
process.exitCode = 1; |
| 43 |
break; |
| 44 |
} |
| 45 |
} |