Skip to content

Commit 342fed6

Browse files
fix: skip prebundling of .remote.js files (#14583)
* fix: skip prebundling of .remote.js files * robustify * Update packages/kit/src/exports/vite/index.js Co-authored-by: Simon H <[email protected]> --------- Co-authored-by: Simon H <[email protected]>
1 parent dcddc33 commit 342fed6

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.changeset/late-ways-find.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: skip prebundling of .remote.js files

packages/kit/src/exports/vite/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,23 @@ async function kit({ svelte_config }) {
298298
`${kit.files.routes}/**/+*.{svelte,js,ts}`,
299299
`!${kit.files.routes}/**/+*server.*`
300300
],
301+
esbuildOptions: {
302+
plugins: [
303+
{
304+
name: 'vite-plugin-sveltekit-setup:optimize',
305+
setup(build) {
306+
if (!kit.experimental.remoteFunctions) return;
307+
308+
const filter = new RegExp(
309+
`.remote(${kit.moduleExtensions.join('|')})$`.replaceAll('.', '\\.')
310+
);
311+
312+
// treat .remote.js files as empty for the purposes of prebundling
313+
build.onLoad({ filter }, () => ({ contents: '' }));
314+
}
315+
}
316+
]
317+
},
301318
exclude: [
302319
// Without this SvelteKit will be prebundled on the client, which means we end up with two versions of Redirect etc.
303320
// Also see https://github.com/sveltejs/kit/issues/5952#issuecomment-1218844057

0 commit comments

Comments
 (0)