Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Babel plugin to transpile import() to require, for AMD module loaders

License

Notifications You must be signed in to change notification settings

genkgo/babel-plugin-dynamic-import-amd

Repository files navigation

babel-plugin-dynamic-import-amd

Babel plugin to transpile import() to require, for AMD module loaders

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

Build Status

Installation

$ npm install babel-plugin-dynamic-import-amd --save-dev

Usage

Via .babelrc (Recommended)

.babelrc

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

Via CLI

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

Via Node API

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

Syntax

Now just use syntax from the proposal for adding a "function-like" import() module loading syntactic form to JavaScript. It is currently in stage 3 of the TC39 process.

import('module-name');

let name = '-name';
import(`module-${name}`);

Credits

Many credits go to AirBNB's package babel-plugin-dynamic-import-webpack. This package contains the same tests as that library. And it formed the base for the actual dynamic import implementation.

About

Babel plugin to transpile import() to require, for AMD module loaders

Resources

License

Stars

Watchers

Forks

Packages

No packages published