We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c26e63 commit 83c7c7fCopy full SHA for 83c7c7f
src/plugins/swc-target.ts
@@ -1,3 +1,4 @@
1
+import type { ModuleConfig } from '@swc/core/types';
2
import { PrettyError } from '../errors'
3
import { Plugin } from '../plugin'
4
import { localRequire } from '../utils'
@@ -23,7 +24,7 @@ export const swcTarget = (): Plugin => {
23
24
},
25
26
async renderChunk(code, info) {
- if (!enabled || !/\.(cjs|js)$/.test(info.path) || this.format !== 'cjs') {
27
+ if (!enabled || !/\.(cjs|mjs|js)$/.test(info.path)) {
28
return
29
}
30
const swc: typeof import('@swc/core') = localRequire('@swc/core')
@@ -55,6 +56,9 @@ export const swcTarget = (): Plugin => {
55
56
57
: undefined,
58
59
+ module: {
60
+ type: this.format === 'cjs' ? 'commonjs' : 'es6'
61
+ } as ModuleConfig,
62
})
63
return {
64
code: result.code,
0 commit comments