Skip to content

Published npm package ships sourcemaps pointing to missing source files #2

@threepointone

Description

@threepointone

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions