Variable name mapping issue *only* when using ModuleConcatentationPlugin

Hi WP Team, congrats on the major version bump, and thank you for all of your hard work this year! Filing this in response to a tweet, would be great to get ETA on docs for ModuleConcatentationPlugin. We’re aware it’s an experimental feature. Keep us posted. Thanks!

Do you want to request a feature or report a bug?

What is the current behavior?
Medium sized JS app. 80k LOC, 100s of modules.
Switching Webpack 2.6.1 to 3.0.0 works fine, no issues.
Build fails when adding ModuleConcatentationPlugin().

With no other configuration changes, I get the following output:

ERROR in chunk main [entry]
Cannot map to variable name in module /Users/sdt/te/frontend/src/app/domainData/api/entities/elements/index.js (export 'COMMON_HEADERS')

Again, this only happens when adding ModuleConcatentationPlugin, build works fine without it.

If the current behavior is a bug, please provide the steps to reproduce.
Gist, with full config.
Uploaded BuildOutput.txt.

Unfortunately, my team is on a deadline and I’m unable to provide a minimal reproduceable repo. I’m filing this issue in hopes that someone has an idea of what might be wrong. I’ve tried this >6 times with re-cloning of the repos and a restart of my machine. It’s possible I’ve left something out and this is a simple fix.

The best I can do is upgrade us to 3.0.0 (which doesn’t break our builds), and stay on top of this issue. If you have tips for how to create a minimal repo, let me know — seems tough with how big our project is, I’m unsure where to start creating a failure case from a smaller repo. I’ve subscribed to the issue and am happy to provide more context: thanks for your attention!

What is the expected behavior?
The failed mapping is an api constant (for headers) and used in over a dozen other files successfully in 2.6.1, both in prod and dev builds. We have changed only two things: webpack version, and a one-line addition of the plugin.

The expected behavior is to not get this error (or any other future errors), and have a successful build.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Browser Version: Version 58.0.3029.110 (64-bit)
Node Version: v6.9.4
Webpack Version: 3.0.0
OS: OSX Sierra, Version 10.12.4 (16E195)

Author: Fantashit

4 thoughts on “Variable name mapping issue *only* when using ModuleConcatentationPlugin

  1. @epoberezkin – I’m open. Can you please elaborate a little as to why you think it’s a circular dep? We’ve dealt with that issue before.

    Noting again that it works in WP2, the only change is adding this plugin:

    Switching Webpack 2.6.1 to 3.0.0 works fine, no issues.
    Build fails when adding ModuleConcatentationPlugin().
  2. No one “needs” circular dependencies. ESM strict implementations won’t even
    allow them.

    Circular dependencies are allowed by the ESM spec. Implementations that doesn’t allow circular dependencies are not spec conform. webpack and also the scope hoisting plugins allows circular dependencies. At least it should, if it doesn’t this is a bug.

Comments are closed.