modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.22k stars 291 forks source link

wtr: fails to compile standard decorators #2757

Open tpluscode opened 4 months ago

tpluscode commented 4 months ago

I have been recently struggling with lit where it complained about shadows class fields. While exploring options to address that issue, I found that WTR fails to compile my elements with lit decorators. Simply gives me

SyntaxError: Invalid or unexpected token

Repro on master branch: https://github.com/tminuscode/wtr-decorators

Also fails Works with legacy decorators: https://github.com/tminuscode/wtr-decorators/tree/legacy-decorators, when tsconfig path is

Either way works fine when compiling to JS first: https://github.com/tminuscode/wtr-decorators/tree/js

This is the behavior with @web/dev-server-esbuild@1.0.2.

tpluscode commented 4 months ago

I also tried with @web/dev-server-esbuild@0.4.4.

"useDefineForClassFields": false has no effect and I still get the shadowing error from lit. Trying to add the accessor keyword results in a different error from wtr

Error while transforming elements.ts: Expected ";" but found "name"
   7 |
   8 |     @property({ type: String })
>  9 |     accessor name: string = "Sombeody"
tpluscode commented 4 months ago

I further tried adding tsconfig path in wtr config as mentioned on https://github.com/lit/lit/issues/3807 but it made no difference