Skip to content

Commit 9c933a2

Browse files
Alazlidummdidumm
andauthored
Fix Syntax Errors in Remote Module Code Concatenation (#14728)
* Fix Syntax Errors in Remote Module Code Concatenation Problem Remote module transformation fails with syntax errors when the source file ends with an expression or a comment and does not include a trailing semicolon, space, or newline. This results in invalid concatenated code. Root Cause When Vite transforms .remote.js files, it concatenates the generated code with the original module. If the original module ends with an expression (e.g. console.log) or a comment without a trailing newline, the resulting code becomes syntactically invalid. * chore: add changeset * Apply suggestion from @dummdidumm * Apply suggestion from @dummdidumm --------- Co-authored-by: Simon H <[email protected]>
1 parent c4f28a1 commit 9c933a2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
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: resolve remote module syntax errors with trailing expressions

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@ async function kit({ svelte_config }) {
755755
remotes.push(remote);
756756

757757
if (opts?.ssr) {
758-
code += dedent`
758+
// Extra newlines to prevent syntax errors around missing semicolons or comments
759+
code += '\n\n' + dedent`
759760
import * as $$_self_$$ from './${path.basename(id)}';
760761
import { init_remote_functions as $$_init_$$ } from '@sveltejs/kit/internal';
761762

0 commit comments

Comments
 (0)