fix(build): stop publishing dangling source/declaration maps#36
Open
dmchaledev wants to merge 1 commit into
Open
fix(build): stop publishing dangling source/declaration maps#36dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
The published tarball ships `dist` only (package.json "files"), not `src`, but the build emitted .js.map and .d.ts.map files that all reference ../src/*.ts. Those source files are absent from the package, so every map was a dangling pointer: debugger source mapping and IDE "Go to Definition" (the whole purpose of declaration maps) resolved to files that don't exist. Disable sourceMap and declarationMap in tsconfig.build.json (keeping declaration:true — the .d.ts types are public API). This removes 12 broken map files from the tarball and cuts unpacked size 49.5kB -> 28.6kB. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0121jPWdufr9tbgebBZAa5f9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The published npm tarball ships 12 map files that all point at source that isn't in the package.
package.json'sfilesfield publishesdistonly (notsrc), but the build emits*.js.mapand*.d.ts.mapwhosesourcesall reference../src/*.ts. Sincesrc/is never published, every one of those maps is a dangling pointer.Concretely, on the current
main:Impact
.d.ts.map) exist for exactly one reason: IDE "Go to Definition" jumping from a consumer's editor into the original.ts. Withsrc/absent, that navigation resolves to a file that doesn't exist — the feature is shipped broken and misleading..js.map) break debugger source mapping the same way: stepping into the library resolves to non-existent../src/*.ts.Change
Disable
sourceMapanddeclarationMapintsconfig.build.json(the config used bynpm run build→ the publisheddist).declaration: trueis kept — the.d.tstypes are public API and must stay. Local dev/typecheck config (tsconfig.json) is untouched.This makes the package internally consistent: it stops shipping maps it can't back with source.
Result
Alternative considered
The other way to make the maps resolve is to add
srctofilesand keep the maps, giving consumers go-to-definition into real TS. That's a legitimate product choice but bloats the tarball with raw sources; for a compiled library, dropping the maps is the standard, minimal-footprint fix. Happy to switch to the ship-srcapproach instead if source navigation into the package is desired.Verification
npm run typecheck— cleannpm run lint— cleannpm test— 29/29 passnpm run build+ CLI smoke test — unchanged output;distnow contains.js+.d.tsonlynpm pack --dry-run— 0 map files, 6.d.tsretainedNot a duplicate
None of the open issues (#9, #21, #22, #26, #27, #30) or PRs touch source maps, the
filesarray, or published tarball integrity. This is confined to one build-config file and composes cleanly with everything in flight.🤖 Generated with Claude Code
https://claude.ai/code/session_0121jPWdufr9tbgebBZAa5f9
Generated by Claude Code