babel-plugin-dynamic-import-webpack

Babel plugin to transpile import() to require.ensure, for Webpack

  • Owner: airbnb/babel-plugin-dynamic-import-webpack
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

babel-plugin-dynamic-import-webpack

Babel plugin to transpile import() to require.ensure, for Webpack.

Note that Webpack 2 has gotten import() after this code was written.

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

Installation

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

Usage

.babelrc

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

Via CLI

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

Via Node API

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

Dynamic imports and webpack

Although the specification for import() supports a dynamic importing of modules in the browser runtime, webpack's require.ensure() is not dynamic and requires a hardcoded string to work correctly. For more information see webpack's documentation on dynamic imports.

Main metrics

Overview
Name With Ownerairbnb/babel-plugin-dynamic-import-webpack
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2016-10-17 03:24:19
Pushed At2024-06-04 00:44:43
Last Commit At2024-06-03 17:20:30
Release Count4
Last Release Namev1.1.0 (Posted on )
First Release Namev1.0.0 (Posted on )
用户参与
Stargazers Count496
Watchers Count34
Fork Count33
Commits Count54
Has Issues Enabled
Issues Count24
Issue Open Count7
Pull Requests Count21
Pull Requests Open Count2
Pull Requests Close Count10
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private