Unexpected code after tree-shake

Do you want to request a feature or report a bug?
Either a bug or unclear docs.

What is the current behavior?
Given entry is the entry module:
screen shot 2018-01-08 at 17 19 34

It just uses function1 from external1 module.

I expected that external1.function2 and the whole external2 module would be eliminated.

However, my output includes external2.function1. Just.. why?

Here’s a repo of the whole thing.

Author: Fantashit

9 thoughts on “Unexpected code after tree-shake

  1. This doesn’t work yet. We don’t do this kind of scope analysis yet, but this is prepared in some places and could be added.

  2. By using ModuleConcatenationPlugin, webpack does eliminate external2 stuff correctly.

    Here’s output from webpack 4 with ModuleConcatenationPlugin and UglifyJSPlugin: gist link.

  3. @dmwyatt Thanks for following. My plugin has been released for a while, and I rarely receive bugs report. I don’t know if it’s really tested by the community even though I have a lot of unit tests. Because shaking wrong modules would make production code crash. I am worried.

    @sokra Maybe I could submit a PR for integrating the plugin as an optional parameter, people can choose to use it.

  4. Work done in webpack@5. Provided example works with latest beta (webpack@5.0.0-beta.14).

    I think this issue could be closed @evilebottnawi

Comments are closed.