-
Notifications
You must be signed in to change notification settings - Fork 598
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
Publish sources and source maps to npm #2867
Comments
Solution 2 does sound reasonable. In the pre-TS world, we published "source" code too. Publishing both source maps and source code would enable debugging in the TS source code, good stacktraces, etc. I remember reading something from Microsoft recently about them recognizing the need to end up in TS source code when debugging code that calls NPM package code. I'll try to find it. |
Related: We should prolly publish the "declaration source maps" too microsoft/TypeScript#14479 |
@bcoe this all started when some joker said we shouldn't publish source maps with our modules 🤣 Mind chatting with @soldair on this one? I have no opinion one way or the other, and trust whatever y'all decide. |
There is no reasonable way for end users to modify and compile the typescript in dependencies. The published packages dont have the config files and dev dependencies to make a useful debugging experience. Having traces that go through code you cant compile makes it easier to link lines of code into issues on github but makes it grep luck to insert a console.log in the correct place and debug yourself. This is why we decided to go with no source maps. We had already stopped shipping source and extra files some time ago to reduce the download size of published tarballs. Now if stack traces included the line numbers and file paths to the source and the compiled output this wouldn't be an issue and might be kinda cool. |
had a good conversation with @soldair about this today. I think inline source-maps (
Where things get more exiting though, are plans that are partially in the works to add source-map support into Node.js itself (and potentially V8) -- the first pass at this design will likely favor inline source-maps. |
Hi @bcoe - Better platform support for sourcemaps would be hugely useful. Is there a repo or wiki for this work? I'd like to follow progress. I'm unfamiliar with inline sourcemaps. Is that where the original source is appended (as a data URI) to the end of the transpiled bundle js file? Is there a way to avoid downloading the sourcemap when not debugging? |
@justingrant I'm working with a mentee on the Node.js project to experiment with adding some initial source-map support to Node.js, our work is going to be logged here. |
Also, could you please remove references to source maps from the code when it does not exist? Otherwise, the parcel build complains about it. It still has: |
👋 returning to this conversation after a long break 😆I've come around to @soldair's point of view (at least partially), with the realization that it source maps would increase the size of yargs by 70%. I am of the mind that source-maps are useful in environments where the source doesn't exist, because a lot of the time a library maintainer simply wants a user to deliver a stack trace (they don't need the upstream user to have the source). In fact, Node.js just got fancy source-map support, making it quite valuable to ship source maps for the purposes of stack traces. My current thinking, Is I'd like to come up with a convention for releasing debug versions of libraries, which include source-maps, while continuing to release the main version without (cutting down on library size significantly). |
Hi @bcoe, thanks for all the work you're doing to make sourcemaps and debugging better! Hey, is there a prioritized list of user-facing problems and use-cases that need to be solved via improving library sourcemaps? My sense is that one source of disagreement in the community has stemmed from different ideas about what users need most. For example, if your conception of debugging is "fire up an IDE debugger, set breakpoints/logpoints, and then single-step through code to figure out the root cause of an error or unexpected result" then you'll have different instincts for what's important vs. if your preferred debugging strategy for library dependencies is "insert console.log statements in library code". IMHO, the prioritized requirements are something like this:
Does that match what you're thinking? If not, how would you change or re-order that list, and why?
I have some questions & concerns with this convention:
My sense is that an easier approach might be to extend package managers (npm, yarn), bundlers (webpack, rollup, parcel, etc), and debuggers (VSCode, Chrome, Firefox, Sentry, etc.) with small but globally-applicable tooling changes that would still allow debug files to be removed but wouldn't add as much extra work for maintainers and for library consumers. Here's one idea about how this could work. I'm curious to know what you think!
Would something like this be workable? |
@justingrant sorry for the slow reply:
I think you have some good ideas. It's similar to what my colleague @murgatroid99 suggested, the difference being that he suggested a debug package that lives beside your library, and can be installed automatically by the tooling (not dissimilar to how DefinitelyTyped has introduced types for a variety of libraries in the community). The advantage of having things in their own package is that npm delivers your module as one I think a good place to continue this conversation might be the Node.js package maintenance group, and/or the npm RFCs repo. If we can come up with a better community practice, than I would happily follow it with the libraries I maintain for GCP. |
…ood discussion of the topic)
In the attempt to publish our libraries in dual-format for ESM & CJS, we've decided against publishing source maps to reduce the overall package size. |
@JustinBeckwith @kinwa91 Yesterday the
@google-cloud
projects were modified to remove source maps from their npm packages with the stated rationale, "When a user runs code in an environment that enables source maps their stack traces end in code that doesn't exist." It seems to me there are two solutions to this issueUnless I'm missing something, solution 2 is way better, and in my experience including sources and maps is a standard best practice when publishing compiled npm packages. I know my workflow depends on both being present.
The text was updated successfully, but these errors were encountered: