Closed npejo closed 7 years ago
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 if (action === actions.DEVELOP)
clause, but the integration test fails to execute actions.BUILD
with dynamic import in the code.
When I moved the plugin out of the if
, to be always required, Babel is not complaining any more 🙂
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
.