Skip to content

Destructuring $state array causes build to errorΒ #16093

@WaltzingPenguin

Description

@WaltzingPenguin

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

> [email protected] 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

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