-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: using source maps for better stack traces #2975
base: v2
Are you sure you want to change the base?
feat: using source maps for better stack traces #2975
Conversation
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.
I don't mind mentioning this, but the current wording seems to be pretty repetitive; it's three sentences that say "By shipping ...".
de7dcc8
to
3f8aa58
Compare
3f8aa58
to
3915aeb
Compare
@jakebailey I improved the text a little bit! |
- **`sourceMap: true`** and **`declarationMap: true`** emit source maps for the output JavaScript and type declaration files, respectively. These are only useful if the library also ships its source (`.ts`) files. By shipping source maps and source files, consumers of the library will be able to debug the library code somewhat more easily. By shipping declaration maps and source files, consumers will be able to see the original TypeScript sources when they run Go To Definition on imports from the libraries. Both of these represent a tradeoff between developer experience and library size, so it’s up to you whether to include them. | ||
- **`sourceMap: true`** emits source maps for the output JavaScript files. By shipping source maps, when consumers of the library execute the code with source maps enabled (e.g. via [`node --enable-source-maps`](https://nodejs.org/docs/latest-v18.x/api/cli.html#--enable-source-maps)), stack traces of errors will point to the original source TypeScript files (instead of the emitted output JavaScript files). When the source files are also shipped with the library, source maps allow consumers of the library to debug the library code somewhat more easily. | ||
- **`declarationMap: true`** emits source maps for the output type declaration files. By shipping declaration maps and source files, consumers will be able to see the original TypeScript sources when they run Go To Definition on imports from the libraries. | ||
- Note that **`sourceMap: true`** and **`declarationMap: true`** represent a tradeoff between developer experience and library size, so it’s up to you whether to include them. |
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.
The pattern here has been for each bullet to be about a specific compiler option, but this one is clarifying the previous lines. I'm not sure how to do better, though.
In the section about
I’m writing a library
, regardingsourceMap: true
anddeclarationMap: true
, the docs currently state:IMO source maps for the output JavaScript files can also be useful for better stack traces.
I added a sentence for that and removed the hint quoted above (because for better stack traces the source maps alone are sufficient; the source files don't need to be distributed also).