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.
$ npm install babel-plugin-dynamic-import-webpack --save-devVia
.babelrc
(Recommended)
.babelrc
{ "plugins": ["dynamic-import-webpack"] }
$ babel --plugins dynamic-import-webpack script.js
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4