@@ -11,12 +11,14 @@ export const swcDefaultsFactory = (
11
11
? configuration . compilerOptions . builder . options
12
12
: { } ;
13
13
14
- // SWC编译器选项
14
+ // Define SWC compiler options with sensible defaults
15
15
const swcOptions = {
16
+ // Enable source maps based on TypeScript config
16
17
sourceMaps : tsOptions ?. sourceMap || ( tsOptions ?. inlineSourceMap && 'inline' ) ,
17
18
module : { type : 'commonjs' } ,
18
19
jsc : {
19
- target : 'es2021' ,
20
+ // Use modern ES2021 target for better performance
21
+ target : 'es2021' ,
20
22
parser : {
21
23
syntax : 'typescript' ,
22
24
decorators : true ,
@@ -28,24 +30,29 @@ export const swcDefaultsFactory = (
28
30
useDefineForClassFields : false ,
29
31
} ,
30
32
keepClassNames : true ,
33
+ // Preserve TypeScript path mappings
31
34
baseUrl : tsOptions ?. baseUrl ,
32
35
paths : tsOptions ?. paths ,
33
36
} ,
34
37
minify : false ,
35
38
swcrc : true ,
36
39
} ;
37
40
38
- // CLI选项
41
+ // CLI build configuration
39
42
const cliOptions = {
43
+ // Use TypeScript outDir or default to 'dist'
40
44
outDir : tsOptions ?. outDir ? convertPath ( tsOptions . outDir ) : 'dist' ,
45
+ // Source files location with fallback
41
46
filenames : [ configuration ?. sourceRoot ?? 'src' ] ,
47
+ // Default CLI behavior
42
48
sync : false ,
43
- extensions : [ '.js' , '.ts' ] ,
49
+ extensions : [ '.js' , '.ts' , '.tsx' ] ,
44
50
copyFiles : false ,
45
51
includeDotfiles : false ,
46
52
quiet : false ,
47
53
watch : false ,
48
54
stripLeadingPaths : true ,
55
+ // Override defaults with any builder options
49
56
...builderOptions ,
50
57
} ;
51
58
0 commit comments