Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including babel-plugin-dynamic-import-split-require with all npm packages installed. Try it out:

var babelPluginDynamicImportSplitRequire = require("babel-plugin-dynamic-import-split-require")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

babel-plugin-dynamic-import-split-require v2.0.0

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

babel-plugin-dynamic-import-split-require

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

v2+ of this plugin works with split-require@3.1.0 and up. Install babel-plugin-dynamic-import-split-require@1.x if you are using an older version.

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free