Quiet optimized dependency sourcemap warnings#4646
Conversation
Preview deploymentsHost Test Results 1 files ± 0 1 suites ±0 1h 44m 12s ⏱️ - 3h 29m 39s Results for commit 0bf39eb. ± Comparison against earlier commit dffbbca. Realm Server Test Results 1 files ± 0 1 suites ±0 18m 29s ⏱️ +11s Results for commit 0bf39eb. ± Comparison against earlier commit dffbbca. |
There was a problem hiding this comment.
Pull request overview
This PR adds a Vite dev-server middleware in packages/host to patch optimized dependency sourcemaps on the fly so Vite stops emitting repeated sourcemap warnings during pnpm start.
Changes:
- Adds a serve-only Vite plugin that intercepts optimized dependency requests under
node_modules/.vite/deps. - Reads matching
.js.mapfiles and pads missingsourcesContententries before Vite continues serving the dependency. - Wires the new middleware into the host app’s Vite plugin list.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review on #4646: - Skip the file read + JSON parse on every optimized-dep request after the first by tracking padded map paths in a Set. - Read the real source file from disk for missing sourcesContent slots instead of writing empty strings. The Vite warning fires precisely because those paths escape the package boundary; reading them ourselves quiets the warning while preserving DevTools source-level debugging of vendor code. Falls back to an empty string if the read fails. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
sourcesContententries from pnpm package paths outsidepackages/host/node_modules/.vite, which removes the repeated "Sourcemap for ... points to a source file outside its package" warnings.Validation
pnpm startinpackages/hostbefore the change.sourcesContentlength matchessourceslength.mise exec -- pnpm lintinpackages/host.mise exec -- pnpm buildinpackages/host.