DanielSchaffer / webpack-babel-multi-target-plugin

A Webpack plugin that works with Babel to allow differential loading - production deployment of ES2015 builds targeted to modern browsers, with an ES5 fallback for legacy browsers.
153 stars 14 forks source link

[2.5.0-next.2] ContextReplacementPlugin apparently ignored #78

Open jlowcs opened 4 years ago

jlowcs commented 4 years ago

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`);
jlowcs commented 4 years ago

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.

DanielSchaffer commented 4 years ago

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