Skip to content

Commit fc9a0d2

Browse files
committed
fix: no default value for sourceType
1 parent b4d07f4 commit fc9a0d2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ export const Oxc: UnpluginInstance<Options | undefined, false> = createUnplugin(
123123
},
124124
)
125125

126-
function guessSourceType(id: string, format?: string): 'module' | 'script' {
126+
function guessSourceType(
127+
id: string,
128+
format?: string,
129+
): 'module' | 'script' | undefined {
127130
if (format === 'module' || format === 'module-typescript') {
128131
return 'module'
129132
} else if (format === 'commonjs' || format === 'commonjs-typescript') {
130133
return 'script'
131-
} else {
132-
return getModuleFormat(id) === 'module' ? 'module' : 'script'
133134
}
135+
const moduleFormat = getModuleFormat(id)
136+
if (moduleFormat) return moduleFormat === 'module' ? 'module' : 'script'
134137
}

0 commit comments

Comments
 (0)