Skip to content

Support Typescript decorator metadata #87

@nitedani

Description

@nitedani

Vite uses esbuild to transpile TypeScript into JavaScript
Esbuild doesn't support emitting typescript decorator metadata. evanw/esbuild#257

Solution: avoid Vite's esbuild transpilation and use swc instead. (until Rolldown is here and supports this)

There are multiple ways to do add the swc transform:

Setting esbuild: false in Vite config,
Adding the swc transform using the Vite transform hook:
Example implementation: https://github.com/unplugin/unplugin-swc/blob/main/src/index.ts

Adding an esbuild plugin to esbuild.plugins that does the swc transform:
Example implementation: https://github.com/Fullscript/esbuild-plugin-swc/blob/main/src/index.ts

So the implementation would be pretty simple.
We can add a config to enable this behavior, so this wouldn't be the default, but it could be enabled.
Something like: server.swc: boolean | Options, default: false

Alternatively we can mention this shortcoming in the docs and guide users to add support themselves. (to avoid including unnecessary dependencies in vike-server, swc downloads around 30MB of binaries)

But it would be nice to have support built-in. 😄

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions