How to use the @babel/preset-env/data/built-ins.json function in @babel/preset-env

To help you get started, we’ve selected a few @babel/preset-env examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github babel / babel / packages / babel-polyfill / scripts / make-separate-polyfill-files.js View on Github external
"use strict";

const fs = require("fs");
const path = require("path");

function relative(loc) {
  return path.join(__dirname, "..", loc);
}

const builtIns = require("@babel/preset-env/data/built-ins.json");
const polyfills = Object.keys(builtIns);

polyfills
  .concat(["web.timers", "web.immediate", "web.dom.iterable"])
  .forEach(polyfill => {
    fs.writeFileSync(
      relative(`src/core-js/modules/${polyfill}.js`),
      `require("core-js/modules/${polyfill}");`
    );
  });

fs.writeFileSync(
  relative("src/regenerator-runtime/runtime.js"),
  'require("regenerator-runtime/runtime");'
);