aurelia: bindable decorator should not be giving a runtime error
🐛 Bug Report
bindable decorator is giving a runtime error.
🤔 Expected Behavior
should not give the error
😯 Current Behavior
bindable decorator is giving runtime error:
Uncaught TypeError TypeError: Cannot read properties of undefined (reading ‘au:annotation:bindables’) at decorator (c:\Users\dkent\Documents\Projects\douglaskent\node_modules@aurelia\runtime-html\src\bindable.ts:102:40) at bindable (c:\Users\dkent\Documents\Projects\douglaskent\node_modules@aurelia\runtime-html\src\bindable.ts:110:5)
It is happening on this line:
where context equals the string “inline” and context.metadata is undefined.
baseline equals ‘au:annotation:bindables’
💁 Possible Solution
🔦 Context
I’m stuck. The app won’t run. You may reproduce as follows:
- clone the repo and look at this commit: https://github.com/dkent600/douglaskent/commit/1a5de33f0fd1effdcff7285ff5fbdead83042a00
- run
npm install - run ‘npm run start’
You will see the error message in the browser console.
💻 Code Sample
I am using this repo at this commit: https://github.com/dkent600/douglaskent/commit/1a5de33f0fd1effdcff7285ff5fbdead83042a00
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Aurelia | v2.0.0-beta.17 |
| Language | Typescript, v5.4.2 |
| Browser | Edge |
| Bundler | vite and rollup |
| Operating System | Windows 11 |
| NPM/Node/Yarn | NPM 10.5.0 |
Definitely love Aurelia, for a long time
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 28 (14 by maintainers)
Fixed by https://github.com/aurelia/aurelia/issues/1980#issuecomment-2138430275
Thanks for everyone’s help!
This setting does fix the issue. I will put it in our WIP vite skeleton.
Oh yes. Probably esbuild’s decorator helper (in the compiled code) is for legacy decorator spec (honours experimentalDecorators), while Aurelia’s decorator is using latest spec.
Yes we should, completely missed it, thanks @3cp
@dkent600 I tried to debug by removing everything and only had these:
main.tsvite.config.tsAnd it still couldn’t compile the decorator! Will check further.
Hi @dkent600, it seems like a vite+esbuild issue. As the latest esbuild added support for the native decorators, it is worth updating the version of esbuild. Moreover, as the parameter decorators are not yet supported by the new decorator specs, those instances needs to be refactored. The Au2 release notes mention this.
I have tried the aforementioned changes in your repo. Here is a change.patch that you can apply and check.
However, it seems that the decorators are still not transpiled. Unfortunately, I am not much familiar with vite and/or esbuild. @3cp @bigopon Do you guys notice anything configuration change that needs to be made in order to transpile the code view vite/esbuild?