-
Notifications
You must be signed in to change notification settings - Fork 32
Load babel-plugin-syntax-dynamic-import
plugin
#385
Load babel-plugin-syntax-dynamic-import
plugin
#385
Conversation
babel-plugin-syntax-dynamic-import
on dev buildsbabel-plugin-syntax-dynamic-import
for development builds
@@ -50,7 +50,8 @@ export default { | |||
// see: https://github.com/babel/babel/issues/4702 | |||
...(action === actions.DEVELOP || action === actions.TEST_UNIT ? [ | |||
[require.resolve('babel-plugin-transform-react-jsx-source'), {}], | |||
[require.resolve('babel-plugin-transform-react-jsx-self'), {}] | |||
[require.resolve('babel-plugin-transform-react-jsx-self'), {}], | |||
[require.resolve('babel-plugin-syntax-dynamic-import'), {}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be only available in development mode. You could use the dynamic import feature for production builds as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have an integration test that tests this "dynamic import" syntax to see if it really works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dynamic imports are handled natively by webpack >= 2. This plugin is a "syntax", not "transform", and it should be in dev only just for babel to not fail on parsing.
babel-plugin-syntax-dynamic-import
for development buildsbabel-plugin-syntax-dynamic-import
plugin
Dynamic imports are handled natively by webpack >= 2. This plugin is a "syntax", not "transform", and it should be in dev only (and not for production) just for babel to not fail on parsing. |
@deepsweet you can still use dynamic imports in production code, and that code needs to be understood by Babel (even if Webpack supports it), correct? Or am I missing something? |
You are right. |
Initially I added the plugin under the |
From Webpack2 we can use dynamic imports to asynchronously load modules in the project. Even Webpack will understands the
import()
statement, Babel will fail to parse this code if we don't install the appropriate plugins.To avoid this issue, we can use the
babel-plugin-syntax-dynamic-imports
.