Skip to content

SvelteKit build error with incorrect message, unable to use decorators #14139

@trusktr

Description

@trusktr

Describe the bug

I bootstrapped an app with sv create, choosing the minimal setup with TypeScript.

It is giving me an incorrect error message that tells me I'm doing what it says I should be doing:

Screenshot 2024-11-03 at 8 37 46 PM

Reproduction

https://github.com/trusktr/sveltekit-issue-14139 (commit f4cbe816ad3d0bb10449964ad0fa0e137cfcbf5e)

git clone [email protected]:trusktr/sveltekit-issue-14139.git
cd sveltekit-issue-14139
git checkout f4cbe816ad3d0bb10449964ad0fa0e137cfcbf5e
npm ci
npm run build

Logs

> vite build

vite v5.4.10 building SSR bundle for production...
✓ 38 modules transformed.
x Build failed in 94ms
error during build:
src/lib/index.ts (11:0): Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead. (Note that you need plugins to import files that are not JavaScript)
file: /Users/trusktr/src/svelte-example/src/lib/index.ts:11:0

 9: 
10: export
11: @element('kitchen-sink')
    ^
12: class KitchenSink extends Element {}

    at getRollupError (file:///Users/trusktr/src/svelte-example/node_modules/rollup/dist/es/shared/parseAst.js:395:41)
    at ParseError.initialise (file:///Users/trusktr/src/svelte-example/node_modules/rollup/dist/es/shared/node-entry.js:13252:28)
    at convertNode (file:///Users/trusktr/src/svelte-example/node_modules/rollup/dist/es/shared/node-entry.js:14963:10)
    at convertProgram (file:///Users/trusktr/src/svelte-example/node_modules/rollup/dist/es/shared/node-entry.js:14206:12)
    at Module.setSource (file:///Users/trusktr/src/svelte-example/node_modules/rollup/dist/es/shared/node-entry.js:15949:24)
    at async ModuleLoader.addModuleSource (file:///Users/trusktr/src/svelte-example/node_modules/rollup/dist/es/shared/node-entry.js:19827:13)

System Info

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M2
    Memory: 36.94 MB / 8.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 20.6.1 - ~/.n-node-versions/bin/node
    Yarn: 1.22.19 - ~/.n-node-versions/bin/yarn
    npm: 10.5.2 - ~/.npm-packages/bin/npm
    pnpm: 9.0.5 - ~/.npm-packages/bin/pnpm
    Watchman: 2023.11.27.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 110.1.48.158
    Chrome: 130.0.6723.92
    Chrome Canary: 132.0.6816.0
    Safari: 18.0.1
    Safari Technology Preview: 18.0
  npmPackages:
    svelte: ^5.0.0 => 5.1.9 

Severity

blocking usage of decorators in SvelteKit

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