You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To better support minification of the generated code we need to change the default settings by adding the following to the tsconfg.base.json.
This changed should be applied to ALL generated packages in both the JS and Contrib repo's
"importHelpers": true,
"noEmitHelpers": true
And include the relevant version of tslib as a dependency so that during packaging all dependencies can be resolved.
What does this do?
By enabling these settings rather than TypeScript emitting JavaScript code for the "helper" (which are also included in tslib) it will emit code to import tslib. While this does not sound like much by default when TypeScript emits the helper inline this causes multiple instances of the helpers to get included in a bundle (1 for each usage scenario) which results in unnecessary additional duplicate functions.
For some metrics, simply adding these settings to the opentelemetry web sandbox and letting it generate the complete bundles results in the following size reductions, where Raw is the bundle created by Rollup (with tree-shaking) for the package and Min is the minified version of that raw JS file.
Package
Current (UMD Module) bytes
With Import helpers (UMD Module) bytes
Minfied Bundle Saving
@opentelemetry/api
Raw: 49,512; Min: 19,706
Raw:43,570; Min: 17,612
~2k
@opentelemetry/core
Raw: 97,026; Min: 36,727
Raw: 85,238; Min: 32,383
~4k
@opentelemetry/sdk-trace-web
Raw: 175,118; Min: 66,719
Raw: 152,126; Min: 58,094
~8k
The bundles generated by the sandbox are self contained and include all of their dependencies (include the single tslib instance).
Additional context
Discussed during the June 14th, 2023 Sig meeting.
The text was updated successfully, but these errors were encountered:
To better support minification of the generated code we need to change the default settings by adding the following to the tsconfg.base.json.
This changed should be applied to ALL generated packages in both the JS and Contrib repo's
And include the relevant version of tslib as a
dependency
so that during packaging all dependencies can be resolved.What does this do?
By enabling these settings rather than TypeScript emitting JavaScript code for the "helper" (which are also included in tslib) it will emit code to import tslib. While this does not sound like much by default when TypeScript emits the helper inline this causes multiple instances of the helpers to get included in a bundle (1 for each usage scenario) which results in unnecessary additional duplicate functions.
For some metrics, simply adding these settings to the opentelemetry web sandbox and letting it generate the complete bundles results in the following size reductions, where Raw is the bundle created by Rollup (with tree-shaking) for the package and Min is the minified version of that raw JS file.
The bundles generated by the sandbox are self contained and include all of their dependencies (include the single tslib instance).
Additional context
Discussed during the June 14th, 2023 Sig meeting.
The text was updated successfully, but these errors were encountered: