-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Description
Feature request
What is the expected behavior?
In my application, I am seeing various external modules (specifically those with side-effect only imports, i.e. "import "myModule"") being removed by tree shaking from the bundle when in production mode.
According to the tree shaking documentation, I can mark npm packages as having side effects / not having side-effects, but that same option is not documented for external modules (even when using the function method of identifying externals).
What is motivation or use case for adding/changing the behavior?
I would like to preserve these imports since webpack can't really know if I need them or not.
My current workaround is to use "require" on only these imports (since only "import" statements are eligible for treeshaking), but that's hard to remember and I'd love to flag all externals as non-treeshakable.
How should this be implemented in your opinion?
Either
- Change the tree-shaking algorithm to ignore all external modules
- Provide a new input parameter (or options object) to the callback function for the externals function that allows specifying whether the external has side-effects or not.
Are you willing to work on this yourself?
Likely, if this isn't already secretly supported and there's buy-in on which of the two approaches to take.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status