milomg / reactively

MIT License
415 stars 23 forks source link

Vite uses esbuild internally which lacks decorator support #4

Closed snnsnn closed 1 year ago

snnsnn commented 1 year ago

I see you working on decorators and just wanted to let you know vite uses esbuild internally and consequently does not support decorators. Vite becoming the defacto devtool, this may pose a major hurdle for adoption.

https://github.com/evanw/esbuild/issues/104

mighdoll commented 1 year ago

That's a savvy thing to worry about, but I think we're ok.

Decorators work well using Typescript and esbuild and vite. And @reactively decorated Typescript classes can be used seamlessly from Javascript.

If someone wants to write classes with reactive properties in Javascript using esbuild or vite, there are three options:

  1. configure esbuild to compile Javascript as Typescript (as @evanw suggests in the esbuild issue above.)
  2. manually add get/set accessors in your class backed by a hidden Reactive object. (That's all the decorator library does)
  3. build a convenience library to make get/set accessors in Javascript. (contributions welcome!)