I am creating shared modules that contain dynamic imports for code splitting.
I have code like:
import('./moduleA').then(/* do stuff */)
However babel compiles this to a deferred require which stops Webpack from code splitting.
The transformed result looks like:
Promise.resolve().then(() => require('./moduleA')).then(/* do stuff */)
My .babelrc.json
is simple and only contains:
{
"presets": ["@babel/preset-env"]
}
How can I preserve the dynamic imports in my babel transformed code?