Skip to content

Commit 913fdf5

Browse files
committed
chore: migrate to @oxc-project/runtime
1 parent 8c63e53 commit 913fdf5

File tree

3 files changed

+17
-54
lines changed

3 files changed

+17
-54
lines changed

packages/vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
8787
"dependencies": {
88-
"@babel/runtime": "^7.26.0",
88+
"@oxc-project/runtime": "^0.51.0",
8989
"lightningcss": "^1.29.1",
9090
"postcss": "^8.5.3",
9191
"rolldown": "1.0.0-beta.3-commit.1910872"

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

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -356,61 +356,17 @@ export function oxcPlugin(config: ResolvedConfig): Plugin {
356356
resolveId: {
357357
// @ts-expect-error TODO: fix the types
358358
filter: {
359-
id: /^@babel\/runtime\//,
359+
id: /^@oxc-project\/runtime\//,
360360
},
361361
async handler(id, _importer, opts) {
362-
if (!id.startsWith('@babel/runtime/')) return
362+
if (!id.startsWith('@oxc-project/runtime/')) return
363363

364-
if (
365-
id === '@babel/runtime/helpers/decorate' ||
366-
id === '@babel/runtime/helpers/decorateParam'
367-
) {
368-
return id
369-
}
370-
371-
// @babel/runtime imports will be injected by OXC transform
372-
// since it's injected by the transform, @babel/runtime should be resolved to the one Vite depends on
364+
// @oxc-project/runtime imports will be injected by OXC transform
365+
// since it's injected by the transform, @oxc-project/runtime should be resolved to the one Vite depends on
373366
const resolved = await this.resolve(id, _filename, opts)
374367
return resolved
375368
},
376369
},
377-
// TODO: applied a workaround for now
378-
load: {
379-
handler(id) {
380-
if (id === '@babel/runtime/helpers/decorateParam') {
381-
return `function __decorateParam(paramIndex, decorator) {
382-
return function (target, key) {
383-
decorator(target, key, paramIndex);
384-
};
385-
}
386-
387-
export { __decorateParam as default };`
388-
}
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-
}
412-
},
413-
},
414370
async transform(code, id) {
415371
if (filter(id) || filter(cleanUrl(id))) {
416372
const modifiedOxcTransformOptions = getModifiedOxcTransformOptions(

pnpm-lock.yaml

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)