Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

babel-plugin-dynamic-import-node

Package Overview
Dependencies
Maintainers
9
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-dynamic-import-node

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

latest
Source
npmnpm
Version
2.3.3
Version published
Weekly downloads
5.3M
-6.63%
Maintainers
9
Weekly downloads
 
Created
Source

babel-plugin-dynamic-import-node

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

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

Installation

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

Usage

.babelrc

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

Options

  • noInterop - A boolean value, that if true will not interop the require calls. Useful to avoid using require('module').default on commonjs modules.
{
  "plugins": [
    ["dynamic-import-node", { "noInterop": true }]
  ]
}

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*/
  });

Keywords

babel

FAQs

Package last updated on 21 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts