Socket
Socket
Sign inDemoInstall

babel-plugin-dynamic-import-node

Package Overview
Dependencies
14
Maintainers
9
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

babel-plugin-dynamic-import-node

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

    2.3.3latest
    GitHub
    npm

Version published
Maintainers
9
Weekly downloads
6,805,075
increased by5.13%

Weekly downloads

Changelog

Source

v2.3.3

  • [Fix] Generate webpack-compatible output with static string arg (#84)
  • [Fix] Handle visiting the same path gracefully (#71)

Readme

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

FAQs

Last updated on 21 Apr 2020

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc