Replies: 3 comments
-
|
Oxc (which replaced esbuild in Vite 8) does not support lowering TC39 Stage 3 decorators. Legacy TS decorators ( The workaround from the Vite 8 migration guide: use import babel from "@rolldown/plugin-babel"
export default defineConfig({
plugins: [
babel({
presets: [{
preset: () => ({ plugins: [["@babel/plugin-proposal-decorators", { version: "2023-11" }]] }),
rolldown: { filter: { code: "@" } },
}],
}),
],
})SWC is also an option via |
Beta Was this translation helpful? Give feedback.
-
|
We hit the same issue with Stage 3 decorators after upgrading to Vite 8. Current workaround is import { defineConfig } from "vite";
import babel from "@rolldown/plugin-babel";
function decoratorPreset(options: Record<string, unknown>) {
return {
preset: () => ({
plugins: [["@babel/plugin-proposal-decorators", options]],
}),
rolldown: {
filter: { code: "@" },
},
};
}
export default defineConfig({
plugins: [
babel({
presets: [decoratorPreset({ version: "2023-11" })],
}),
],
});npm install -D @rolldown/plugin-babel @babel/plugin-proposal-decorators
|
Beta Was this translation helpful? Give feedback.
-
|
None of the proposed solutions work when the class' name is used by the decorator: Babels strips names and SWC generates assignment to class' |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In our organization we're using stage 3 decorators quite a lot: in some internal libraries, but also with this open source library. Our main rationale is to move towards ECMAScript standards instead of keeping legacy TypeScript decorators "alive".
This worked fine with Vite 7:
However, with Vite 8 we now have a big problem: since it's dropping
esbuildin favor of Rolldown (with oxc), we're gettingNow our whole tool chain breaks down — since, we're also using Vitest.
Is there a workaround? Or should we rewrite all our libraries to use the legacy TypeScript decorators instead?
Beta Was this translation helpful? Give feedback.
All reactions