Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack not removing unused side-effect-free library from build #18541

Closed
MJez29 opened this issue Jun 28, 2024 · 1 comment
Closed

Webpack not removing unused side-effect-free library from build #18541

MJez29 opened this issue Jun 28, 2024 · 1 comment

Comments

@MJez29
Copy link

MJez29 commented Jun 28, 2024

Bug report

I have a library file that is used by both the client and the server that contains utilities for working with routes

One utility used only by the client uses react-router-dom

What is the current behavior?

When compiling the server build webpack is correctly eliminating the dead code that uses react-router-dom but it is not removing the react-router-dom import

If the current behavior is a bug, please provide the steps to reproduce.

I believe that this is a bug because the react-router-dom library is tagged with sideEffects: false in its package.json

I have created a minimal reproduction here: https://github.com/MJez29/webpack-harmony-side-effect-evaluation

In the logs I see

    | external "react-router-dom" 42 bytes [depth 2] [dependent] [built]
    |   [no exports used]
    |   harmony side effect evaluation react-router-dom ./src/lib.js 1:0-45
    |   [inactive] harmony import specifier react-router-dom ./src/lib.js 4:9-18

What is the expected behavior?

I expect react-router-dom to be completely removed from the build output because it is not used and it is labeled as not having any side effects

Other relevant information:
webpack version: 5.92.1
Node.js version: v20.12.2
Operating System:
Additional tools:

@alexander-akait
Copy link
Member

Sorry for delay, yeah, we don't remove external side effect free modules right now, it is a feature, duplicate of #15486

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants