Skip to content

feat(plugin-vue): use transformWithOxc if rolldown-vite is detected #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,42 @@ export async function transformMain(
/tsx?$/.test(lang) &&
!descriptor.script?.src // only normal script can have src
) {
const { code, map } = await transformWithEsbuild(
resolvedCode,
filename,
{
target: 'esnext',
charset: 'utf8',
// #430 support decorators in .vue file
// target can be overridden by esbuild config target
...options.devServer?.config.esbuild,
loader: 'ts',
sourcemap: options.sourceMap,
},
resolvedMap,
)
resolvedCode = code
resolvedMap = resolvedMap ? (map as any) : resolvedMap
// @ts-ignore Rolldown-specific
const { transformWithOxc } = await import('vite')
if (transformWithOxc) {
const { code, map } = await transformWithOxc(
resolvedCode,
filename,
{
// #430 support decorators in .vue file
// target can be overridden by oxc config target
// @ts-ignore Rolldown-specific
...options.devServer?.config.oxc,
lang: 'ts',
sourcemap: options.sourceMap,
},
resolvedMap,
)
resolvedCode = code
resolvedMap = resolvedMap ? (map as any) : resolvedMap
} else {
const { code, map } = await transformWithEsbuild(
resolvedCode,
filename,
{
target: 'esnext',
charset: 'utf8',
// #430 support decorators in .vue file
// target can be overridden by esbuild config target
...options.devServer?.config.esbuild,
loader: 'ts',
sourcemap: options.sourceMap,
},
resolvedMap,
)
resolvedCode = code
resolvedMap = resolvedMap ? (map as any) : resolvedMap
}
}

return {
Expand Down