Skip to content

Remote functions generating empty sourcemaps #15472

Description

@DJMogens

Describe the bug

The internal vite-plugin-sveltekit-remote Vite plugin's transform hook modifies .remote.* files but doesn't return a map property in either code path (SSR or client). This causes:

Vite build warnings: [plugin vite-plugin-sveltekit-remote] Sourcemap is likely to be incorrect — once per .remote.* file, for both SSR and client builds.
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.
SSR path (~line 727 in src/exports/vite/index.js): Appends init code via string concatenation and returns a bare code string — no map.

Client path (~line 803): Replaces the module entirely and returns { code: result } — no map.

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

transform(src, id) {
  if (fileRegex.test(id)) {
    return {
      code: compileFileToJS(src),
      map: null, // provide source map if available
    }
  }
},

I intend to submit a PR for this.

Reproduction

Stackblitz reproduction:
https://stackblitz.com/~/github.com/DJMogens/sveltejs-kit-sourcemap-bug
To reproduce:

npm install
npm run build   # ← shows warnings + broken sourcemaps

Logs

@sveltejs/kit@2.53.4 ✔
vite v7.3.1 building ssr environment for production...
✓ 201 modules transformed.
[plugin vite-plugin-sveltekit-remote] Sourcemap is likely to be incorrect: a plugin (vite-plugin-sveltekit-remote) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
vite v7.3.1 building client environment for production...
✓ 168 modules transformed.
[plugin vite-plugin-sveltekit-remote] Sourcemap is likely to be incorrect: a plugin (vite-plugin-sveltekit-remote) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help

System Info

(from stackblitz as the bug is also apparent here)
  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^7.0.0 => 7.0.1 
    @sveltejs/kit: ^2.48.5 => 2.53.4 
    @sveltejs/vite-plugin-svelte: ^6.2.1 => 6.2.4 
    svelte: ^5.43.8 => 5.53.6 
    vite: ^7.2.2 => 7.3.1 


My local system where it was first noted:
   OS: Windows 11 10.0.26200
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700K
    Memory: 34.02 GB / 63.76 GB
Binaries:
    Node: 22.17.1
    pnpm: 10.29.3
Browsers:
    Chrome: 145.0.7632.117
    Edge: Chromium (141.0.3537.71)
npmPackages:
    svelte: 5.49.1
    @sveltejs/kit: 2.53.4
    @sveltejs/adapter-node: 5.5.4
    @sveltejs/vite-plugin-svelte: 6.2.0
    vite: 7.1.3

Severity

annoyance

Additional Information

For us this was needed to upload the sourcemaps to sentry.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions