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

Use webpack's side-effects flag #565

Closed
kossnocorp opened this issue Sep 18, 2017 · 3 comments

Comments

@kossnocorp
Copy link
Member

commented Sep 18, 2017

Because of webpack/webpack#2867, webpack doesn't remove all unused code when a user imports a function like that: import { parse } from 'date-fns'

Although, now it's possible to achieve it with a new webpack feature, side-effects: https://github.com/webpack/webpack/tree/next/examples/side-effects.

@kossnocorp

This comment has been minimized.

Copy link
Member Author

commented Sep 21, 2017

Closed by a1b61c3

@kossnocorp kossnocorp closed this Sep 21, 2017

@dmitriid

This comment has been minimized.

Copy link

commented Sep 25, 2017

I’m assuming this only works for entire libraries?

Is it possible to mark separate modules as side-effect free? Can a user of a library which doesn’t have this flag supply the flag for the library or separate modules inside the library?

@kossnocorp

This comment has been minimized.

Copy link
Member Author

commented Sep 26, 2017

@dmitriid when you have package.json only in the root of the library, side-effects flag affects the whole library. If you have package.json in a submodule, the flag (or its absence) affects this submodule. For example, when you import a function from date-fns/esm/fp/index.js, webpack will look into date-fns/esm/fp/package.json.

AFAIK a user of a library can't control it unless they write/update package.json manually.

btw, the source code is there: https://github.com/webpack/webpack/blob/next/lib/optimize/SideEffectsFlagPlugin.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.