Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

babel-plugin-dynamic-import-node-babel-7

mike3run48.5kMIT2.0.7

Babel plugin to transpile import() to a deferred require(), for node

babel, plugin, dynamic, import, node

readme

babel-plugin-dynamic-import-node

FORK OF THE ORIGINAL TO TEST WITH BABEL 7

If you're looking for the original one, check on: Github This fork was created to add support for Babel 7: Github

Babel plugin to transpile import() to a deferred require(), for node. Matches the proposed spec.

NOTE: Babylon >= v6.12.0 is required to correct parse dynamic imports.

Installation

$ npm install babel-plugin-dynamic-import-node-babel-7 --save-dev

Usage

.babelrc

{
  "plugins": ["dynamic-import-node-babel-7"]
}

Via CLI

$ babel --plugins dynamic-import-node script.js

Via Node API

require('babel-core').transform('code', {
  plugins: ['dynamic-import-node']
});

Code Example

Promise.all([
  import('./lib/import1'),
  import('./lib/import2')
 ]).then(([
   Import1,
   Import2
  ]) => {
   console.log(Import1);
   /* CODE HERE*/
  });

changelog

Unreleased

v2.0.7

  • [Update] Update dependencies to babel 42 beta

    v2.0.6

  • [Update] Update dependencies to babel 40 beta

    v2.0.5

  • [Update] Update dependencies

    v2.0.4

  • [Update] Update readme and dependencies

v2.0.3

  • [Update] Add prepare npm hook

v2.0.2

  • [Update] Update dependencies

v2.0.1

  • [Refactor] Tweak readme to point to original repo

v2.0.0

  • [New] Beta status
  • [New] Babel 7 Support

v1.2.0

  • [New] support comments (#37)
  • [Refactor] Use template and types from the babel object (#32)
  • [Tests] on node v9; pin included builds to LTS
  • [Dev Deps] update eslint, eslint-config-airbnb-base, mocha, rimraf

v1.1.0

  • Visit Import nodes instead of CallExpressions (#30)
  • [Deps] update babel-template, babel-types
  • [Dev Deps] update airbnb-js-shims, babel-cli, babel-core, babel-preset-airbnb, babel-register, chai, eslint, eslint-config-airbnb-base, eslint-plugin-import, mocha
  • [Tests] on node v8
  • [Tests] use nvm install-latest-npm so newer npm doesn’t break older node

v1.0.2

  • [Fix] Ensure it works with the ES2015 preset too (#12, #16)
  • [Deps] update babel-template, babel-types
  • [Dev Deps] update babel-cli, babel-core, babel-eslint, babel-register, eslint, eslint-config-airbnb-base, mocha

v1.0.1

  • [Fix] Move in-publish to devDeps (#11)
  • [Fix] ensure dynamic import() input is properly stringified (#2)
  • [Fix] async timing of dynamic import to match spec (#3)
  • [Fix] Remove spaces in template strings and update Babel (#10)
  • [Deps] update babel-template, babel-types
  • [Deps] update babel-types (#4, #5, #6)
  • [Dev Deps] update babel-cli, babel-core, babel-eslint, babel-register, eslint, eslint-config-airbnb-base, eslint-plugin-import, mocha, rimraf

v1.0.0

  • Initial full release.