Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vitePreprocess script is breaking snippet export svelte 5 #15681

Open
neo-noire opened this issue Apr 3, 2025 · 1 comment
Open

vitePreprocess script is breaking snippet export svelte 5 #15681

neo-noire opened this issue Apr 3, 2025 · 1 comment

Comments

@neo-noire
Copy link

Describe the bug

Just figured out that vitePreprocess({ script: true}) is breaking snippets export from <script lang="ts" module> .
I know that you do not need to use script option in svelte5, but not using it will break my enums that are defined inside <script> tags.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-ldkwkg71?file=svelte.config.js

Logs

System Info

System:
    OS: macOS 15.4
    CPU: (10) arm64 Apple M2 Pro
    Memory: 185.34 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.10.0 - ~/.nvm/versions/node/v22.10.0/bin/node
    npm: 10.3.0 - ~/Desktop/work/project_name/node_modules/.bin/npm
    pnpm: 10.5.2 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 134.0.6998.166
    Edge: 134.0.3124.95
    Safari: 18.4
  npmPackages:
    svelte: ^5.19.9 => 5.20.0

Severity

annoyance

@neo-noire
Copy link
Author

neo-noire commented Apr 3, 2025

Edit so if your reprocessor script is set to true , you are not able to to export snippets from lang="ts" module.

This will not work:

<script lang="ts" module>
	export { add }
</script>

{#snippet add(props)}
	{props.a} + {props.b} = {props.a + props.b}
{/snippet}

But this will work:

<script module>
	export { add }
</script>

So there's some issue how it preprocess ts scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant