-
Notifications
You must be signed in to change notification settings - Fork 533
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
feat: add ESM builds for packages used in browser #459
Conversation
Forgive me I'm less familiar with webpack, but what is meta.js? This seems like a decent size savings but honestly less than I would have guessed. I think the lack of effective tree shaking comes from the fact that instrumentation packages only really have a single entry point so almost all of the code in them should be used even after tree shaking. |
Codecov Report
@@ Coverage Diff @@
## main #459 +/- ##
=======================================
Coverage 95.24% 95.24%
=======================================
Files 133 133
Lines 8252 8252
Branches 810 810
=======================================
Hits 7860 7860
Misses 392 392 |
Hmm, after doing more research it could be that more packages need to have a
|
Added as a quick test
But searching further:
So seems like yes it's able to prune away whole files that aren't imported already (so splitting into more files would help), but also But all of this probably worth it's own issue |
Splitting into more files might help but it also complicates the build chain. I'm not sure the code generator we use to generate the semantic conventions package even supports it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, this may be a smaller improvement than the other repos but it seems to still be an improvement so i'll go ahead and approve here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Which problem is this PR solving?
Continuation of open-telemetry/opentelemetry-js-api#25 and open-telemetry/opentelemetry-js#2112:
Related issues: open-telemetry/opentelemetry-js#1378, open-telemetry/opentelemetry-js#1253
Short description of the changes
Added config files for tsc to build esm versions into build/esm of each package that is used in browser (as determined by existence of test:browser script in it's package.json
Effect on bundle size
Test was done by doing
npm pack
on each opentelemetry package used inexamples/web
(including opentelemetry-js-api and packages in opentelemetry-js as esm builds for those haven't been released in npm yet) and then placed in the right folder insideexamples/web/node_modules/@opentelemetry
.Devtool commented out in
examples/web/webpack.config.js
and built usingnpx webpack --mode production --profile --json > stats.json
to generate stats file for better analysis.Comparison using webpack visualizer