node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org »

babel-plugin-dynamic-import-split-require

babel-plugin-dynamic-import-split-require

babel plugin to compile import() syntax to split-require, the commonjs bundle splitting library

npm travis standard

Install

npm install babel-plugin-dynamic-import-split-require

Usage

In .babelrc:

{
  "plugins": [
    "dynamic-import-split-require"
  ]
}

Input

import('whatever').then(onwhatever)

Output

var _import = require('split-require');
 
new Promise(function (resolve, reject) {
  _import("whatever", function (err, exports) {
    if (err) reject(err);else resolve(exports);
  });
}).then(onwhatever);

This code can be bundled by browserify using the split-require plugin.

License

Apache-2.0