How to use the @babel/helpers.list function in @babel/helpers

To help you get started, we’ve selected a few @babel/helpers 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 downshift-js / downshift / other / misc-tests / jest.config.js View on Github external
const jestConfig = require('kcd-scripts/config').jest
const babelHelpersList = require('@babel/helpers').list

module.exports = Object.assign(jestConfig, {
  roots: ['.'],
  testEnvironment: 'jsdom',
  moduleNameMapper: babelHelpersList.reduce((aliasMap, helper) => {
    aliasMap[
      `@babel/runtime/helpers/esm/${helper}`
    ] = `@babel/runtime/helpers/${helper}`
    return aliasMap
  }, {}),
})
github babel / babel / packages / babel-plugin-transform-runtime / scripts / build-dist.js View on Github external
function adjustImportPath(node, relativePath) {
    node.value =
      helpers.list.indexOf(node.value) !== -1
        ? `./${node.value}`
        : node.value.replace(runtimeName + "/", relativePath + "/");
  }
github babel / babel / packages / babel-core / src / tools / build-external-helpers.js View on Github external
function buildHelpers(body, namespace, whitelist) {
  const getHelperReference = name => {
    return namespace
      ? t.memberExpression(namespace, t.identifier(name))
      : t.identifier(`_${name}`);
  };

  const refs = {};
  helpers.list.forEach(function(name) {
    if (whitelist && whitelist.indexOf(name) < 0) return;

    const ref = (refs[name] = getHelperReference(name));

    const { nodes } = helpers.get(name, getHelperReference, ref);

    body.push(...nodes);
  });
  return refs;
}
export default function(
github babel / babel / packages / babel-plugin-transform-runtime / scripts / build-dist.js View on Github external
function writeHelperFiles(runtimeName, { esm, corejs }) {
  const pkgDirname = getRuntimeRoot(runtimeName);

  for (const helperName of helpers.list) {
    const helperFilename = path.join(
      pkgDirname,
      "helpers",
      esm ? "esm" : "",
      `${helperName}.js`
    );

    outputFile(
      helperFilename,
      buildHelper(runtimeName, pkgDirname, helperFilename, helperName, {
        esm,
        corejs,
      })
    );
  }
}

@babel/helpers

Collection of helper functions used by Babel transforms.

MIT
Latest version published 4 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages