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

feat: enable tree shaking #3329

Merged
merged 4 commits into from
Oct 19, 2022
Merged

Conversation

pkanal
Copy link
Contributor

@pkanal pkanal commented Oct 13, 2022

Which problem is this PR solving?

Fixes #2855
Original PR: #3087

This PR essentially re-opens #3087 to enable tree shaking for opentelemetry-js packages. This significantly reduces bundle size when using opentelemetry packages in the browser.

Short description of the changes

  • Marks sideEffects: false in package.json for most packages to signal to bundlers like Webpack that the module can be tree shaken.
  • Setting sideEffects: false should be a safe change here since none of the packages execute code without having a function called. The exception to this is opentelemetry-context-zone which has sideEffects: true because it imports Zone.js which presumably does have some side effects on import.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Tested locally by modifying package.json & looking at a bundle analyzer
  • Tested with the examples in this repo

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@pkanal pkanal requested a review from a team October 13, 2022 21:08
@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Merging #3329 (3a9f748) into main (6ede1ee) will decrease coverage by 0.38%.
The diff coverage is n/a.

❗ Current head 3a9f748 differs from pull request most recent head cd7d823. Consider uploading reports for the commit cd7d823 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3329      +/-   ##
==========================================
- Coverage   93.45%   93.07%   -0.39%     
==========================================
  Files         241      226      -15     
  Lines        7260     6524     -736     
  Branches     1507     1360     -147     
==========================================
- Hits         6785     6072     -713     
+ Misses        475      452      -23     
Impacted Files Coverage Δ
api/karma.worker.js 0.00% <0.00%> (-100.00%) ⬇️
packages/opentelemetry-resources/karma.worker.js 0.00% <0.00%> (-100.00%) ⬇️
...kages/opentelemetry-sdk-trace-base/karma.worker.js 0.00% <0.00%> (-100.00%) ⬇️
...lemetry-resources/src/detectors/BrowserDetector.ts 53.33% <0.00%> (-46.67%) ⬇️
...lemetry-resources/src/detectors/ProcessDetector.ts 95.45% <0.00%> (-4.55%) ⬇️
...ckages/opentelemetry-sdk-trace-web/karma.worker.js
...s/opentelemetry-instrumentation-fetch/src/fetch.ts
...emetry-instrumentation-xml-http-request/src/xhr.ts
...ation-xml-http-request/src/enums/AttributeNames.ts
...es/opentelemetry-context-zone-peer-dep/src/util.ts
... and 10 more

@legendecas
Copy link
Member

@vmarchaud has your concern been resolved?

@vmarchaud
Copy link
Member

@vmarchaud has your concern been resolved?

Sorry i didn't see your answer

@dyladan
Copy link
Member

dyladan commented Oct 19, 2022

Test failure appears to be #3344

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

Successfully merging this pull request may close these issues.

Add sideEffects: false to package.json for packages to enable tree shaking
5 participants