Skip to content

fix: inline source content in sourcemaps to prevent missing source warnings#5

Merged
southpolesteve merged 1 commit intomainfrom
fix/inline-sourcemap-sources
Feb 24, 2026
Merged

fix: inline source content in sourcemaps to prevent missing source warnings#5
southpolesteve merged 1 commit intomainfrom
fix/inline-sourcemap-sources

Conversation

@threepointone
Copy link
Collaborator

Problem

When vinext is installed from npm, 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/shims/navigation.js" points to missing source files
...

The published dist/ includes .js.map files that reference the original .ts source files via "sources", but the .ts files aren't included in the npm package.

Fix

Adds "inlineSources": true to tsconfig.json. This tells tsc to embed the original TypeScript source content directly in the .js.map files via sourcesContent, so no separate source files are needed.

Verified: after building, .js.map files now contain sourcesContent with the full original source.

Fixes #2

…rnings

When vinext is installed from npm, the .ts source files aren't in the
package but .js.map files reference them, causing Vite to log many
'points to missing source files' warnings.

Adding inlineSources: true to tsconfig embeds the original TypeScript
source content directly in the .js.map files so no separate .ts files
are needed.

Fixes #2
@github-actions
Copy link

Example Preview Production Original
app-router-cloudflare preview production
pages-router-cloudflare preview production
app-router-playground preview production original
realworld-api-rest preview production
nextra-docs-template preview production
benchmarks preview production
hackernews preview production original

@southpolesteve southpolesteve merged commit acd1110 into main Feb 24, 2026
17 checks passed
@southpolesteve southpolesteve deleted the fix/inline-sourcemap-sources branch February 24, 2026 17:13
southpolesteve added a commit that referenced this pull request Feb 27, 2026
Bundle middleware.ts into the server entry at build time via generateServerEntry().
The virtual module now imports the middleware file statically and exports a
runMiddleware(request) function that includes matcher logic and NextRequest wrapping.

In prod-server.ts, middleware runs before API route and page routing:
- Redirects (e.g. /old-page -> /about) return 307 with Location header
- Rewrites (e.g. /rewritten -> /ssr) transparently serve the target page
- Blocks (e.g. /blocked -> 403) return the middleware Response directly
- Response headers from NextResponse.next() are applied to all matched requests

Also fixes server.listen() to be awaited (enables port: 0 for tests).

When no middleware.ts exists, runMiddleware is a no-op stub.

App Router middleware already works (bundled in RSC entry) — no changes needed.

12 new tests: 6 unit tests for runMiddleware exports, 6 integration tests
using startProdServer with the pages-basic fixture.

Closes #5
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.

Published npm package ships sourcemaps pointing to missing source files

2 participants