aackerman / circular-dependency-plugin

Detect circular dependencies in modules compiled with Webpack
https://www.npmjs.com/package/circular-dependency-plugin
ISC License
921 stars 47 forks source link

Detection with the ModuleConcatenationPlugin #19

Closed gpoitch closed 7 years ago

gpoitch commented 7 years ago

When using the webpack.optimize.ModuleConcatenationPlugin introduced in webpack 3, it appears that this plugin in unable to detect a lot of circular dependencies.

When removing ModuleConcatenationPlugin, it outputs more warnings.

aackerman commented 7 years ago

Thanks for the info, I haven't done much testing with Webpack 3. I'll look into it.

aackerman commented 7 years ago

@gpoitch I believe these plugins are usually run in order, when you were using the ModuleConcatenationPlugin was it before the CircularDependencyPlugin?

gpoitch commented 7 years ago

I tested both before and after. I believe the issue is that this plugin runs on the 'done' plugin event, at which point the ModuleConcatenationPlugin has already did its thing (merged/hoisted dependencies).

It makes sense that some circular dependencies could actually be eliminated by what the ModuleConcatenationPlugin does, but not all of them. I still saw some undefined imports and no warning from this plugin.

gpoitch commented 7 years ago

@aackerman Here's a minimal reproduction: https://github.com/gpoitch/webpack-circ-dep-bug

aackerman commented 7 years ago

@gpoitch thanks, I imagine this will help a lot in addressing this issue.

aackerman commented 7 years ago

This should be fixed in version 4.1.0

gpoitch commented 7 years ago

👏 thanks!