[GH-ISSUE #2] Published npm package ships sourcemaps pointing to missing source files #2

Closed
opened 2026-05-06 12:36:20 +02:00 by BreizhHardware · 0 comments

Originally created by @threepointone on GitHub (Feb 24, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/2

Description

When vinext is installed from npm (vinext@0.0.1), Vite logs many warnings during dev:

Sourcemap for ".../node_modules/vinext/dist/server/image-optimization.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/server/app-router-entry.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/navigation.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/headers.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/server.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/metadata.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/cache.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/utils/hash.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/fetch-cache.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/cache-runtime.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/navigation-state.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/server/instrumentation.js" points to missing source files
Sourcemap for ".../node_modules/vinext/dist/shims/font-local.js" points to missing source files

Cause

The published dist/ directory includes .js.map files that reference the original TypeScript source files (via "sources" in the sourcemap JSON). However, the source .ts files are not included in the npm package, so Vite cannot resolve the sourcemap references.

This wasn't visible when using vinext as a linked dependency because symlinked packages resolve to the actual source tree where the .ts files exist.

Suggested fix

Either:

  1. Include source files in the npm package by adding "src" to the "files" field in package.json (enables proper source-mapped debugging)
  2. Set "sourcesContent" in the sourcemaps so the source content is inlined into the .js.map files (no separate source files needed)
  3. Strip sourcemaps from the published package if they are not needed by consumers (remove .js.map files and //# sourceMappingURL comments from .js files)

Option 2 is the best balance — consumers get working sourcemaps for debugging without needing the raw source tree.

Impact

Harmless — these are warnings, not errors. The app runs fine. But it's noisy and clutters the terminal during development.

Originally created by @threepointone on GitHub (Feb 24, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/2 ## Description When vinext is installed from npm (`vinext@0.0.1`), Vite logs many warnings during dev: ``` Sourcemap for ".../node_modules/vinext/dist/server/image-optimization.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/server/app-router-entry.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/navigation.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/headers.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/server.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/metadata.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/cache.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/utils/hash.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/fetch-cache.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/cache-runtime.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/navigation-state.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/server/instrumentation.js" points to missing source files Sourcemap for ".../node_modules/vinext/dist/shims/font-local.js" points to missing source files ``` ## Cause The published `dist/` directory includes `.js.map` files that reference the original TypeScript source files (via `"sources"` in the sourcemap JSON). However, the source `.ts` files are not included in the npm package, so Vite cannot resolve the sourcemap references. This wasn't visible when using vinext as a linked dependency because symlinked packages resolve to the actual source tree where the `.ts` files exist. ## Suggested fix Either: 1. **Include source files** in the npm package by adding `"src"` to the `"files"` field in `package.json` (enables proper source-mapped debugging) 2. **Set `"sourcesContent"` in the sourcemaps** so the source content is inlined into the `.js.map` files (no separate source files needed) 3. **Strip sourcemaps** from the published package if they are not needed by consumers (remove `.js.map` files and `//# sourceMappingURL` comments from `.js` files) Option 2 is the best balance — consumers get working sourcemaps for debugging without needing the raw source tree. ## Impact Harmless — these are warnings, not errors. The app runs fine. But it's noisy and clutters the terminal during development.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#2
No description provided.