-
Notifications
You must be signed in to change notification settings - Fork 821
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
Add sideEffects: false to package.json for packages to enable tree shaking #2855
Comments
I think the problem for us to adopt the |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
We talked about this in the SIG meeting and agreed that this is safe for us. Even our modules which have side-effects do not execute those side-effects at load time and require a user to explicitly call a function. This will cause the static analysis of webpack to realize the module is used and not tree-shake it out. |
That would be awesome! Currently open telemetry packages are a no go for my company because it more than double our bundle size just for the sake of being able to trace 😥 |
@ogxd if you have time a PR would be welcome |
I'll do that :) |
I'm working on refactoring the otlp exporters right now. they're a mess |
I would like to pick this up if it's up for grabs. |
It's yours 🙂 |
Apologies if this is not supposed to be a bug type, wasn't sure which issue type fits best!
What version of OpenTelemetry are you using?
1.1.1
What version of Node are you using?
16.14.2
Please provide the code you used to setup the OpenTelemetry SDK
What did you do?
I'm PoCing using opentelemetry-js in a library aimed at web application. It's rather hefty and produces a large js bundle when compiled with parcel or webpack. It seems that tree-shaking does not work with it.
What did you expect to see?
Smaller bundle size :)
What did you see instead?
Huge bundle, all of the code is included, even what isn't used by the library.
Additional context
It seems most packages do not have
"sideEffects"
property set. Manually going tonode_modules
and adding"sideEffects": false
to every@opentelemetry/*
package reduced bundle size by ~40kb! Please consider adding this property to every package.More about it: https://webpack.js.org/guides/tree-shaking/
The text was updated successfully, but these errors were encountered: