Skip to content

fix: return sourcemaps from vite-plugin-sveltekit-remote transform hook#15473

Open
DJMogens wants to merge 3 commits intosveltejs:mainfrom
DJMogens:fix/remote-sourcemaps
Open

fix: return sourcemaps from vite-plugin-sveltekit-remote transform hook#15473
DJMogens wants to merge 3 commits intosveltejs:mainfrom
DJMogens:fix/remote-sourcemaps

Conversation

@DJMogens
Copy link

@DJMogens DJMogens commented Mar 3, 2026

Description

The transform hook in plugin_remote (src/exports/vite/index.js) modifies .remote.* files but doesn't return a map property in either code path. This causes:

  1. Vite build warnings: [plugin vite-plugin-sveltekit-remote] Sourcemap is likely to be incorrect — once per .remote.* file, for both SSR and client builds.
  2. Broken sourcemaps: The resulting .js.map files have sources: [], sourcesContent: [], and semicolon-only mappings. Error monitoring tools (e.g. Sentry) cannot map stack traces back to the original source.

Per the Vite Plugin API docs, transform hooks should return { code, map }.

Closes #15472

Changes

SSR path (~line 727): Uses MagicString (already a dependency) instead of string concatenation, returns { code, map } with a proper sourcemap via ms.generateMap({ hires: true }).

Client path (~line 803): Adds map: { mappings: '' } to signal intentional full module replacement (the generated proxy code doesn't need source mapping back).

Testing

Reproduction repo with build:bug / build:fix scripts: https://github.com/DJMogens/sveltejs-kit-sourcemap-bug

  • pnpm format passes
  • Added changeset

@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: e7ea2ff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@DJMogens DJMogens marked this pull request as draft March 3, 2026 11:04
@svelte-docs-bot
Copy link

@DJMogens DJMogens force-pushed the fix/remote-sourcemaps branch from 4e2e97a to 94d5b3c Compare March 3, 2026 11:22
@DJMogens DJMogens force-pushed the fix/remote-sourcemaps branch from 94d5b3c to d07b5e5 Compare March 3, 2026 11:29
@teemingc teemingc marked this pull request as ready for review March 3, 2026 14:56
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.

Remote functions generating empty sourcemaps

2 participants