Skip to content
This repository has been archived by the owner. It is now read-only.
Babel plugin to transpile import() to require, for AMD module loaders
JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.babelrc
.eslintignore
.eslintrc
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
package.json

README.md

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.

You can’t perform that action at this time.