Skip to content

Can’t use double backslash as children in components #15476

@Paalon

Description

@Paalon

Describe the bug

Can’t use double backslash \\ in the following code:

https://svelte.dev/playground/333ee16c4786473cada88079151bb6db?version=5.22.6

<-- App.svelte -->
<script>
	import Sample from "./Sample.svelte";
</script>

<Sample>Hello!</Sample>

<Sample>\\</Sample>
<-- Sample.svelte -->
<script>
	const { children } = $props();
</script>

<span>{@render children()}</span>

in the following situation:

"devDependencies": {
		"@sveltejs/adapter-auto": "^4.0.0",
		"@sveltejs/kit": "^2.16.0",
		"@sveltejs/vite-plugin-svelte": "^5.0.0",
		"@tailwindcss/vite": "^4.0.0",
		"svelte": "^5.0.0",
		"svelte-check": "^4.0.0",
		"tailwindcss": "^4.0.0",
		"typescript": "^5.0.0",
		"vite": "^6.0.0"
	}

I can’t show the original project that I found the error but I encountered the following error message:

9:37:02 PM [vite] (client) Pre-transform error: Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
  Plugin: vite:import-analysis

and the playground’s minimal reproduction sample emits the following error:

Error compiling component

./App.svelte (36:23): Unterminated string constant (Note that you need plugins to import files that are not JavaScript)

Reproduction

Showed in the above and the playground.

Logs

Showed in the above and the playground.

System Info

System:
    OS: macOS 15.3.1
    CPU: (8) arm64 Apple M3
    Memory: 87.41 MB / 24.00 GB
    Shell: 4.0.0 - /opt/homebrew/bin/fish
  Binaries:
    Node: 23.9.0 - /opt/homebrew/bin/node
    npm: 10.9.2 - /opt/homebrew/bin/npm
  Browsers:
    Safari: 18.3
  npmPackages:
    svelte: ^5.0.0 => 5.22.6

Severity

Blocking my transition from React to Svelte 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions