Skip to content

Stage 3 decorators throwing syntax error #221

Closed as not planned
Closed as not planned
@b3nten

Description

@b3nten

While Vite 5.3 updated esbuild to support stage 3 decorators, and SWC has supported it for a while, when I enable the react plugin it throws the following error (using mobx):

[plugin:vite:react-swc] × Unexpected token `@`. Expected identifier, string literal, numeric literal or [ for the computed key @observable

When I disable the plugin it works fine, but of course I don't have react refresh anymore. Here is my vite config:

import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  plugins: [
    tailwindcss(),
    react({
      devTarget: "es2022",
    })
  ],
  css: {
    transformer: "lightningcss"
  },
  esbuild: {
    target: "es2022"
  }
})```

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