Skip to content

Commit fd74ed5

Browse files
committed
feat: lazy load oxc-transformer
1 parent df52dd0 commit fd74ed5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/core/transformer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { isolatedDeclaration } from 'oxc-transform'
21
import type { TranspileOptions } from 'typescript'
32

43
export interface TransformResult {
54
code: string
65
errors: Array<string>
76
}
87

9-
export function oxcTransform(id: string, code: string): TransformResult {
8+
export async function oxcTransform(
9+
id: string,
10+
code: string,
11+
): Promise<TransformResult> {
12+
const { isolatedDeclaration } = await import('oxc-transform')
1013
return isolatedDeclaration(id, code, { sourcemap: false })
1114
}
1215

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const IsolatedDecl: UnpluginInstance<Options | undefined, false> =
9797
let result: TransformResult
9898
switch (options.transformer) {
9999
case 'oxc':
100-
result = oxcTransform(id, code)
100+
result = await oxcTransform(id, code)
101101
break
102102
case 'swc':
103103
result = await swcTransform(id, code)

0 commit comments

Comments
 (0)