-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
We currently only support parsing of import(foo), and ask people to use wither webpack or babel-plugin-dynamic-import-node to transpile it.
I think that we can easily add it to @babel/plugin-transform-modules-* (or create new @babel/plugin-proposal-dynamic-import-* packages):
// input
import(source)
// commonjs
new Promise(resolve => resolve(_interopRequireWildcard(require(source))))
// amd
new Promise(resolve => require([source], imports => resolve(_interopRequireWildcard(imports))))
// systemjs
System.import(source)My preference would be to add this feature (behind an option) to the existing plugins, since we can't transpile import() without also transpiling es6 import/export.
If you prefer the separte plugins, we could add an "internal option" to @babel/plugin-transform-modules-* which is enabled by @babel/plugin-proposal-dynamic-import. If the modules plugin is not enabled, @babel/plugin-proposal-dynamic-import would throw an error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue