lume / classy-solid

Solid.js reactivity patterns for classes, and class components. See https://github.com/lume/element for a Custom Element system built with classy-solid.
MIT License
52 stars 2 forks source link

Document steps needed to use decorators with vite #2

Closed GodBleak closed 1 year ago

GodBleak commented 2 years ago

I think many use Vite with Solid, but I noticed there aren't any instructions on using classy-solid with Vite. Using the example car class from the readme will cause errors with Vite if it's not configured to use decorators (Support for the experimental syntax 'decorators' isn't currently enabled).

To do so, one can install @babel/plugin-proposal-class-properties, and @babel/plugin-proposal-decorators. Then update their vite.config.ts file to include:

// ...
solidPlugin({
     babel: {
          plugins: [
               ["@babel/plugin-proposal-decorators", { legacy: true }],
               "@babel/plugin-proposal-class-properties",
          ]
     },
}),
// ...

I think it would be beneficial to add this or similar instructions to the readme.

trusktr commented 2 years ago

Nice, thanks, may as well copy this to the README