Nepotistic Pontifex Maximus

    babel-plugin-transform-system-import-commonjs

    1.0.3 • Public • Published

    babel-plugin-transform-system-import-commonjs

    Babel plugin that transforms ES2015 System.import into CommonJS require.

    Deprecation notice

    ** Since import() proposal was accepted, System.import function now is obsolete and this plugin is not recommended to use in new projects. Please use import() function with babel-plugin-transform-import-commonjs instead. **

    How this works

    This plugin transforms

    var myModule = "./path/to/myModule";
     
    System.import(myModule).then(function (module) {
      console.log(module);
    });

    to

    var myModule = "./path/to/myModule";
     
    new Promise(function(resolve) {
      resolve(require(myModule));
    }.bind(this)).then(function (module) {
      console.log(module);
    });

    Requirements

    You need support for Promise, use polyfill if needed.

    Installation

    $ npm install babel-plugin-transform-system-import-commonjs

    Usage

    Via .babelrc (Recommended)

    .babelrc

    {
      "plugins": ["transform-system-import-commonjs"]
    }

    Via CLI

    $ babel --plugins transform-system-import-commonjs script.js

    Via Node API

    require("babel-core").transform("code", {
      plugins: ["transform-system-import-commonjs"]
    });

    Install

    npm i babel-plugin-transform-system-import-commonjs

    DownloadsWeekly Downloads

    6

    Version

    1.0.3

    License

    MIT

    Last publish

    Collaborators

    • kiurchv