Skip to content

build: emit sourcemaps for CJS and ESM builds#124

Merged
buffcode merged 1 commit intomasterfrom
feat/sourcemaps
Apr 22, 2026
Merged

build: emit sourcemaps for CJS and ESM builds#124
buffcode merged 1 commit intomasterfrom
feat/sourcemaps

Conversation

@buffcode
Copy link
Copy Markdown
Owner

@buffcode buffcode commented Apr 22, 2026

Summary

  • Enables sourceMap, declarationMap, and inlineSources in tsconfig.base.json, so both CJS and ESM builds emit .js.map / .d.ts.map files with TypeScript source embedded.
  • Maps ship inside npm pack automatically — files: ["dist"] already covers them; no files or .npmignore change needed.
  • Tarball unpacked size grows from ~78 KB to ~142 KB (gzipped: 28 KB) — driven by inlined sources.

Why inlineSources

We publish only dist/ (not src/), so external sources paths in the .map files would be dangling on consumers' machines. Inlining the TS source into sourcesContent is the standard fix for libraries and makes sourcemaps self-contained.

Verification

  • Clean rebuild produces .js.map + .d.ts.map for every .js / .d.ts in both dist/cjs/ and dist/esm/.
  • Each emitted .js ends with //# sourceMappingURL=...map.
  • sourcesContent[0] in the map files contains the full TS source.
  • npm pack --dry-run lists 16 map files in the tarball.
  • With node --enable-source-maps, a thrown error from a built CJS/ESM entrypoint resolves to src/NtpTimeSync.ts:<line> (verified locally).
  • CJS and ESM integration tests still pass; examples/example.js still runs.

Test plan

  • CI green across Node 20/22/24/25 matrix (build + CJS + ESM integration).
  • Deno matrix still green.
  • Prettier workflow still green.

🤖 Generated with Claude Code

Enable sourceMap, declarationMap, and inlineSources in the shared
tsconfig so both build flavors emit .js.map and .d.ts.map files with
TypeScript sources embedded. Maps ship automatically via the existing
files: ["dist"] entry in package.json, giving consumers readable
stack traces pointing at src/*.ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@buffcode buffcode self-assigned this Apr 22, 2026
@buffcode buffcode merged commit eacdc33 into master Apr 22, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant