You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have found this issue #11891 but my problem still remaining:
try to write something like this
exportclassModel{accessorcounter: number=0;}
and run vite build, you obtain this result:
vite v5.4.10 building for production...
✓ 7 modules transformed.
x Build failed in 1.15s
error during build:
src/model.ts (2:11): Unexpected token `counter`. Expected *for generator, private key, identifier or async (Note that you need plugins to import files that are not JavaScript)
file: /home/projects/accessor-class-field-not-supported-by-vite/src/model.ts:2:11
1: export class Model {
2: accessor counter: number = 0;
^
3: }
at Module.getRollupError (file:///home/projects/accessor-class-field-not-supported-by-vite/node_modules/.pnpm/rollup@4.24.4/node_modules/rollup/dist/es/shared/parseAst.js:558:41)
at ParseError.initialise (file:///home/projects/accessor-class-field-not-supported-by-vite/node_modules/.pnpm/rollup@4.24.4/node_modules/rollup/dist/es/shared/node-entry.js:13306:41)
at convertNode (file:///home/projects/accessor-class-field-not-supported-by-vite/node_modules/.pnpm/rollup@4.24.4/node_modules/rollup/dist/es/shared/node-entry.js:15017:10)
at convertProgram (file:///home/projects/accessor-class-field-not-supported-by-vite/node_modules/.pnpm/rollup@4.24.4/node_modules/rollup/dist/es/shared/node-entry.js:14260:12)
at Module.setSource (file:///home/projects/accessor-class-field-not-supported-by-vite/node_modules/.pnpm/rollup@4.24.4/node_modules/rollup/dist/es/shared/node-entry.js:16003:24)
at async ModuleLoader.addModuleSource (file:///home/projects/accessor-class-field-not-supported-by-vite/node_modules/.pnpm/rollup@4.24.4/node_modules/rollup/dist/es/shared/node-entry.js:19881:13)
ELIFECYCLE Command failed with exit code 1.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
It seems rollup does not support parsing auto-accessors and esbuild cannot enable auto-accessors transform separately from decorators.
Maybe we can set esbuild.supported.decorators: false by default, but I'm not sure about the impact of doing that.
Describe the bug
Hi, I have found this issue #11891 but my problem still remaining:
try to write something like this
and run
vite build
, you obtain this result:Stackblitz demo: https://stackblitz.com/edit/accessor-class-field-not-supported-by-vite?file=src%2Fmodel.ts
EsBuild playground: https://esbuild.github.io/try/#dAAwLjI0LjAAewogIGxvYWRlcjogJ3RzJywKICB0YXJnZXQ6ICJFUzIwMjQiLAp9AGZ1bmN0aW9uIGRlY28oKSB7fQoKY2xhc3MgUHJvdmEgewogIGFjY2Vzc29yIGN1c3RvbTogc3RyaW5nID0gIiI7Cn0
Reproduction
https://stackblitz.com/edit/accessor-class-field-not-supported-by-vite?file=src%2Fmodel.ts
Steps to reproduce
open https://stackblitz.com/edit/accessor-class-field-not-supported-by-vite?file=src%2Fmodel.ts and look the error in the Terminal after the build
System Info
Used Package Manager
pnpm
Logs
Validations
The text was updated successfully, but these errors were encountered: