Skip to content

[Bug]: Fails to bundle .svelte.ts files with TypeScript syntax #5081

@ilokhov

Description

@ilokhov

Reproduction link or steps

https://github.com/ilokhov/rolldown-svelte-ts/

What is expected?

Should successfully bundle on npm run build.

What is actually happening?

Getting the following error:

[plugin svelte] src/index.svelte.ts:1:7
SyntaxError: Unexpected token (1:7)
    at En.raise (node_modules/svelte/compiler/index.js:1:91615)
    at ln.unexpected (node_modules/svelte/compiler/index.js:1:35479)
    at un.parseVar (node_modules/svelte/compiler/index.js:1:47505)
    at un.parseVarStatement (node_modules/svelte/compiler/index.js:1:44613)
    at un.parseStatement (node_modules/svelte/compiler/index.js:1:38823)
    at un.parseTopLevel (node_modules/svelte/compiler/index.js:1:36780)
    at an.parse (node_modules/svelte/compiler/index.js:1:32460)
    at an.parse (node_modules/svelte/compiler/index.js:1:33735)
    at qs (node_modules/svelte/compiler/index.js:1:223728)
    at e.compileModule (node_modules/svelte/compiler/index.js:1:781190)

    at normalizeErrors (node_modules/rolldown/dist/shared/src-DHXNdTPA.mjs:2321:18)
    at handleOutputErrors (node_modules/rolldown/dist/shared/src-DHXNdTPA.mjs:3256:34)
    at transformToRollupOutput (node_modules/rolldown/dist/shared/src-DHXNdTPA.mjs:3250:2)
    at RolldownBuild.write (node_modules/rolldown/dist/shared/src-DHXNdTPA.mjs:4459:10)
    at async bundleInner (node_modules/rolldown/dist/cli.mjs:1583:16)
    at async bundleWithConfig (node_modules/rolldown/dist/cli.mjs:1499:7)
    at async main (node_modules/rolldown/dist/cli.mjs:1733:3)

System Info

System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 367.64 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
    pnpm: 10.12.1 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
Browsers:
    Chrome: 138.0.7204.49
    Safari: 18.5
npmPackages:
    rolldown: ^1.0.0-beta.20 => 1.0.0-beta.20

Any additional comments?

I'm using rollup-plugin-svelte to bundle Svelte. In Svelte 5 it's possible to define reactive state inside .svelte.ts files. However using combination of rolldown and rollup-plugin-svelte results in an error when trying to bundle - it looks like TypeScript syntax is not recognised in .svelte.ts files.

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions