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: add esnext target for auto-instr-web package #1848

Conversation

JamieDanielson
Copy link
Member

Which problem is this PR solving?

Short description of the changes

  • Adds esnext build target for the auto-instrumentations-web metapackage
  • Adds esm build to "files" along with the newly built esnext builds.

Copy link

codecov bot commented Dec 7, 2023

Codecov Report

Merging #1848 (9a25365) into main (67bb0ca) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1848   +/-   ##
=======================================
  Coverage   91.45%   91.45%           
=======================================
  Files         144      144           
  Lines        7406     7406           
  Branches     1483     1483           
=======================================
  Hits         6773     6773           
  Misses        633      633           

"build/esm/**/*.js.map",
"build/esm/**/*.d.ts",
"build/esnext/**/*.js",
"build/esnext/**/*.js.map",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't block this PR, but I was comparing to https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/web/opentelemetry-instrumentation-document-load/package.json#L36-L46 and I noticed it uses .../*.map instead of .../*.js.map.

% find build -name "*.map"
build/test/documentLoad.test.js.map
build/test/index-webpack.js.map
build/test/index-webpack.d.ts.map
build/test/documentLoad.test.d.ts.map
build/esm/types.js.map
...

There are also *.d.ts.map files. I wonder if those files are superfluous for end-users so restricting to just *.js.map as is done here is better (just for having a smaller npm install size).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I'm not actually sure why we include source maps the way we do.

End users may create source maps for when they bundle their code, as it helps bring them from unreadable bundled code back to their source. I assume we have them to help map from the built JavaScript code back to the original TypeScript code.

I started walking through this with @opentelemetry/instrumentation-document-load. The maps indicate the TypeScript source file which we don't actually include in the published build. The instrumentation.js.map file for example shows "sources":["../../src/instrumentation.ts"], which doesn't actually exist in the build. If we included the TypeScript source file in the published build, then it would be useful, but otherwise I don't think it actually does anything.

As an example: If I am using new DocumentLoadInstrumentation() in my app, and in my IDE I click to Go to Definition, it brings me to instrumentation.d.ts. If I include src in the files for the published build and then reinstall, then clicking on new DocumentLoadInstrumentation() in my app brings me to a instrumentation.ts package.

I'm not sure if we want to include the whole TypeScript source in a published build (and obviously that's not something to decide either way on this PR), but without it, I actually don't think any of these maps are necessary at all 🤔 . Happy to be pointed out where I might be missing something though!

"compilerOptions": {
"rootDir": "src",
"outDir": "build/esnext",
"jsx": "react",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "jsx" option needed for this package? It is specified for plugins/web/opentelemetry-plugin-react-load/tsconfig.* but not for other packages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm probably not, I'll remove that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the jsx option since there are no .tsx files in this package and added skipLibCheck to skip type checking of declaration files, matching the tsconfig for esm.

@JamieDanielson JamieDanielson merged commit 3cb2802 into open-telemetry:main Dec 8, 2023
14 checks passed
@dyladan dyladan mentioned this pull request Dec 8, 2023
@JamieDanielson JamieDanielson deleted the jamie.esnext-web-auto-target branch January 4, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[opentelemetry/auto-instrumentations-web] esm directory missing in release 0.34.0
2 participants