How to use the @babel/plugin-transform-modules-commonjs.default function in @babel/plugin-transform-modules-commonjs

To help you get started, we’ve selected a few @babel/plugin-transform-modules-commonjs 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 facebook / metro / packages / metro-babel-register / src / babel-register.js View on Github external
*
 * @format
 */
'use strict';

const escapeRegExp = require('escape-string-regexp');
const path = require('path');
require('./node-polyfills');

var _only = [];

const PLUGINS = [
  [require('@babel/plugin-transform-flow-strip-types').default],
  [require('@babel/plugin-proposal-object-rest-spread').default],
  [require('@babel/plugin-proposal-class-properties').default],
  [require('@babel/plugin-transform-modules-commonjs').default],
  [require('@babel/plugin-proposal-nullish-coalescing-operator').default],
  [require('@babel/plugin-proposal-optional-catch-binding').default],
  [require('@babel/plugin-proposal-optional-chaining').default],
];

if (/^v[0-7]\./.test(process.version)) {
  PLUGINS.push([require('@babel/plugin-transform-async-to-generator').default]);
}

function registerOnly(onlyList) {
  // This prevents `babel-register` from transforming the code of the
  // plugins/presets that we are require-ing themselves before setting up the
  // actual config.
  require('@babel/register')({only: [], babelrc: false});
  require('@babel/register')(config(onlyList));
}
github facebook / metro / packages / metro-babel-register / src / babel-register.js View on Github external
* @format
 */

'use strict';

const escapeRegExp = require('escape-string-regexp');
const path = require('path');
require('./node-polyfills');

var _only = [];

const PLUGINS = [
  [require('@babel/plugin-transform-flow-strip-types').default],
  [require('@babel/plugin-proposal-object-rest-spread').default],
  [require('@babel/plugin-proposal-class-properties').default],
  [require('@babel/plugin-transform-modules-commonjs').default],
  [require('@babel/plugin-proposal-nullish-coalescing-operator').default],
  [require('@babel/plugin-proposal-optional-catch-binding').default],
  [require('@babel/plugin-proposal-optional-chaining').default],
];

if (/^v[0-7]\./.test(process.version)) {
  PLUGINS.push([require('@babel/plugin-transform-async-to-generator').default]);
}

function registerOnly(onlyList) {
  // This prevents `babel-register` from transforming the code of the
  // plugins/presets that we are require-ing themselves before setting up the
  // actual config.
  require('@babel/register')({only: [], babelrc: false, configFile: false});
  require('@babel/register')(config(onlyList));
}
github tbranyen / diffhtml / packages / babel-preset-diffhtml-imports / index.js View on Github external
const { join } = require('path');

const ModuleRewrite = require('babel-plugin-module-rewrite').default;
const ObjectRestSpread = require('@babel/plugin-proposal-object-rest-spread').default;
const ClassProperties = require('@babel/plugin-proposal-class-properties').default;
const ModulesCommonJS = require('@babel/plugin-transform-modules-commonjs').default;
const AddModuleExports = require('babel-plugin-add-module-exports');
const Classes = require('@babel/plugin-transform-classes').default;
const BlockScoping = require('@babel/plugin-transform-block-scoping').default;
const ArrowFunctions = require('@babel/plugin-transform-arrow-functions').default;
const ShorthandProperties = require('@babel/plugin-transform-shorthand-properties').default;
const ObjectDestructuring = require('@babel/plugin-transform-destructuring').default;
const Parameters = require('@babel/plugin-transform-parameters').default;
const Spread = require('@babel/plugin-transform-spread').default;
const TemplateLiterals = require('@babel/plugin-transform-template-literals').default;
const ForOf = require('@babel/plugin-transform-for-of').default;
const ComputedProperties = require('@babel/plugin-transform-computed-properties').default;
const ElementClasses = require('babel-plugin-transform-custom-element-classes');

const esmFunc = join(__dirname, 'utils/replace-esm.js');
const cjsFunc = join(__dirname, 'utils/replace-cjs.js');

@babel/plugin-transform-modules-commonjs

This plugin transforms ES2015 modules to CommonJS

MIT
Latest version published 13 days ago

Package Health Score

95 / 100
Full package analysis

Popular @babel/plugin-transform-modules-commonjs functions