Skip to content

Commit 78db800

Browse files
authored
fix (#733)
1 parent 9f674cd commit 78db800

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/core/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export interface Options {
3030
}
3131

3232
function transformOption(path: string, options?: Options, jest = false): SwcOptions {
33-
const opts = options == null ? {} : options
33+
const opts = options ?? {}
3434
opts.esModuleInterop = opts.esModuleInterop ?? true
35+
const moduleType = options?.module ?? 'commonjs'
3536
return {
3637
filename: path,
3738
jsc: options?.swc?.swcrc
@@ -61,11 +62,15 @@ function transformOption(path: string, options?: Options, jest = false): SwcOpti
6162
minify: false,
6263
isModule: true,
6364
module: options?.swc?.swcrc
64-
? undefined
65+
? undefined
6566
: {
66-
type: options?.module ?? 'commonjs',
67-
noInterop: !opts.esModuleInterop,
68-
},
67+
type: moduleType,
68+
...(moduleType === 'commonjs' || moduleType === 'umd' || moduleType === 'amd'
69+
? {
70+
noInterop: !opts.esModuleInterop,
71+
}
72+
: undefined),
73+
},
6974
sourceMaps: jest || typeof opts.sourcemap === 'undefined' ? 'inline' : opts.sourcemap,
7075
inlineSourcesContent: true,
7176
swcrc: false,

0 commit comments

Comments
 (0)