DanielSchaffer/webpack-babel-multi-target-plugin

[2.5.0-next.2] ContextReplacementPlugin apparently ignored

Opened this issue · 2 comments

Hello!

I'm trying to use the plugin on our app, and everything seems to be working, except for our exclusion of dynamic imported locale files.

For that, we were using ContextReplacementPlugin to only include specific local files from intl-related dependencies. But that plugin does not seem to be compatible with BabelMultiTargetPlugin, as all locale files are now outputted as chunks.

If that's not supposed to happen, do you have any insight at what I might be missing here?

new webpack.ContextReplacementPlugin(/intl\/locale-data\/jsonp$/, /(fr-FR|en-US).js$/),
await import(/* webpackChunkName: "intl/[request]" */ `intl/locale-data/jsonp/${intlLocale}.js`);

Here is a branch where you can reproduce the issues: https://github.com/jlowcs/webpack-babel-multi-target-plugin/tree/bug-ContextReplacementPlugin

When using BabelMultiTargetPlugin, 2 plugin chunks (well, 4 if you count the modern files) are generated by the es6-dynamic-import example.

When using babel-loader, 1 plugin chunk is generated.

@jlowcs thanks for the report, I'll take a look.