Skip to content

Commit 536d540

Browse files
committed
chore: update decorators workaround
1 parent b957a46 commit 536d540

File tree

1 file changed

+27
-1
lines changed
  • packages/vite/src/node/plugins

1 file changed

+27
-1
lines changed

packages/vite/src/node/plugins/oxc.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ export function oxcPlugin(config: ResolvedConfig): Plugin {
361361
async handler(id, _importer, opts) {
362362
if (!id.startsWith('@babel/runtime/')) return
363363

364-
if (id === '@babel/runtime/helpers/decorateParam') {
364+
if (
365+
id === '@babel/runtime/helpers/decorate' ||
366+
id === '@babel/runtime/helpers/decorateParam'
367+
) {
365368
return id
366369
}
367370

@@ -383,6 +386,29 @@ export function oxcPlugin(config: ResolvedConfig): Plugin {
383386
384387
export { __decorateParam as default };`
385388
}
389+
if (id === '@babel/runtime/helpers/decorate') {
390+
return `function __decorate(decorators, target, key, desc) {
391+
var c = arguments.length,
392+
r =
393+
c < 3
394+
? target
395+
: desc === null
396+
? (desc = Object.getOwnPropertyDescriptor(target, key))
397+
: desc,
398+
d;
399+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
400+
r = Reflect.decorate(decorators, target, key, desc);
401+
else
402+
for (var i = decorators.length - 1; i >= 0; i--)
403+
if ((d = decorators[i]))
404+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
405+
return c > 3 && r && Object.defineProperty(target, key, r), r;
406+
}
407+
408+
(module.exports = __decorate),
409+
(module.exports.__esModule = true),
410+
(module.exports["default"] = module.exports);`
411+
}
386412
},
387413
},
388414
async transform(code, id) {

0 commit comments

Comments
 (0)