Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-remote-sourcemaps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: return sourcemaps from `vite-plugin-sveltekit-remote` transform hook
14 changes: 9 additions & 5 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import analyse from '../../core/postbuild/analyse.js';
import { s } from '../../utils/misc.js';
import { hash } from '../../utils/hash.js';
import { dedent, isSvelte5Plus } from '../../core/sync/utils.js';
import MagicString from 'magic-string';
import {
env_dynamic_private,
env_dynamic_public,
Expand Down Expand Up @@ -724,9 +725,10 @@ async function kit({ svelte_config }) {
// triggering a dev server error. By adding a microtask we ensure that the module is fully loaded

// Extra newlines to prevent syntax errors around missing semicolons or comments
code +=
const ms = new MagicString(code);
ms.append(
'\n\n' +
dedent`
dedent`
import * as $$_self_$$ from './${path.basename(id)}';
import { init_remote_functions as $$_init_$$ } from '@sveltejs/kit/internal';

Expand All @@ -738,7 +740,8 @@ async function kit({ svelte_config }) {
fn.__.id = ${s(remote.hash)} + '/' + name;
fn.__.name = name;
}
`;
`
);

// Emit a dedicated entry chunk for this remote in SSR builds (prod only)
if (!dev_server) {
Expand All @@ -753,7 +756,7 @@ async function kit({ svelte_config }) {
}
}

return code;
return { code: ms.toString(), map: ms.generateMap({ hires: true }) };
}

// For the client, read the exports and create a new module that only contains fetch functions with the correct metadata
Expand Down Expand Up @@ -801,7 +804,8 @@ async function kit({ svelte_config }) {
}

return {
code: result
code: result,
map: { mappings: '' }
};
}
};
Expand Down
Loading