-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Description
Describe the bug
Array destructuring from $state causes the build to error. This was working in 5.33.4 but is broken in the latest 5.33.14
Reproduction
Include the line let [level, custom] = $state([10, "Admin"])
in a Svelte file in your project and then attempt to build.
Or:
Repo: https://github.com/WaltzingPenguin/sveltekit-expected-ident
Install project and execute npm run build
Logs
PS C:\Users\Admin\Documents\Web Projects\sveltekit-unexpected-ident> npm run build
> sveltekit-unexpected-ident@0.0.1 build
> vite build
vite v6.3.5 building SSR bundle for production...
✓ 15 modules transformed.
✗ Build failed in 69ms
error during build:
src/routes/unexpected-ident.svelte (2:10): Expected ident (Note that you need plugins to import files that are not JavaScript)
file: C:/Users/Admin/Documents/Web Projects/sveltekit-unexpected-ident/src/routes/unexpected-ident.svelte:2:10
1: <script lang="ts">
2: let [level, custom] = $state([10, "Admin"])
^
3: </script>
at getRollupError (file:///C:/Users/Admin/Documents/Web%20Projects/sveltekit-unexpected-ident/node_modules/rollup/dist/es/shared/parseAst.js:401:41)
at ParseError.initialise (file:///C:/Users/Admin/Documents/Web%20Projects/sveltekit-unexpected-ident/node_modules/rollup/dist/es/shared/node-entry.js:14293:28)
at convertNode (file:///C:/Users/Admin/Documents/Web%20Projects/sveltekit-unexpected-ident/node_modules/rollup/dist/es/shared/node-entry.js:16197:10)
at convertProgram (file:///C:/Users/Admin/Documents/Web%20Projects/sveltekit-unexpected-ident/node_modules/rollup/dist/es/shared/node-entry.js:15440:12)
at Module.setSource (file:///C:/Users/Admin/Documents/Web%20Projects/sveltekit-unexpected-ident/node_modules/rollup/dist/es/shared/node-entry.js:17185:24)
at async ModuleLoader.addModuleSource (file:///C:/Users/Admin/Documents/Web%20Projects/sveltekit-unexpected-ident/node_modules/rollup/dist/es/shared/node-entry.js:21187:13)
System Info
System:
OS: Windows 11 10.0.26100
CPU: (20) x64 13th Gen Intel(R) Core(TM) i5-13600KF
Memory: 48.03 GB / 63.85 GB
Binaries:
Node: 22.13.1 - C:\Program Files\nodejs\node.EXE
npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.2.0 - ~\AppData\Local\pnpm\pnpm.CMD
Browsers:
Edge: Chromium (134.0.3124.83)
Internet Explorer: 11.0.26100.1882
Severity
blocking an upgrade
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Ocean-OS commentedon Jun 6, 2025
It seems to work as expected here.
MotionlessTrain commentedon Jun 6, 2025
It looks like a rollup error. But I don’t see how the JavaScript output from the svelte component could trigger that error
paoloricciuti commentedon Jun 6, 2025
Something similar was fixed recently, which version of svelte are you on?
Ocean-OS commentedon Jun 6, 2025
package.json
says 5.33.14paoloricciuti commentedon Jun 6, 2025
Oh well... here's the generated server code lol
MotionlessTrain commentedon Jun 6, 2025
Whoops, I only checked the client code when I was curious whether I could find it 😄
Ocean-OS commentedon Jun 6, 2025
Found the issue, don't know how this wasn't noticed before
https://github.com/sveltejs/svelte/blob/main/packages%2Fsvelte%2Fsrc%2Fcompiler%2Futils%2Fast.js#L341-L343