@@ -5,49 +5,53 @@ export const swcDefaultsFactory = (
5
5
tsOptions ?: ts . CompilerOptions ,
6
6
configuration ?: Configuration ,
7
7
) => {
8
- const builderOptions =
9
- typeof configuration ?. compilerOptions ?. builder !== 'string'
10
- ? configuration ?. compilerOptions ?. builder ?. options
8
+ // 获取构建器选项
9
+ const builderOptions = configuration ?. compilerOptions ?. builder &&
10
+ typeof configuration . compilerOptions . builder !== 'string'
11
+ ? configuration . compilerOptions . builder . options
11
12
: { } ;
12
13
13
- return {
14
- swcOptions : {
15
- sourceMaps :
16
- tsOptions ?. sourceMap || ( tsOptions ?. inlineSourceMap && 'inline' ) ,
17
- module : {
18
- type : 'commonjs' ,
14
+ // SWC编译器选项
15
+ const swcOptions = {
16
+ sourceMaps : tsOptions ?. sourceMap || ( tsOptions ?. inlineSourceMap && 'inline' ) ,
17
+ module : { type : 'commonjs' } ,
18
+ jsc : {
19
+ target : 'es2021' ,
20
+ parser : {
21
+ syntax : 'typescript' ,
22
+ decorators : true ,
23
+ dynamicImport : true ,
19
24
} ,
20
- jsc : {
21
- target : 'es2021' ,
22
- parser : {
23
- syntax : 'typescript' ,
24
- decorators : true ,
25
- dynamicImport : true ,
26
- } ,
27
- transform : {
28
- legacyDecorator : true ,
29
- decoratorMetadata : true ,
30
- useDefineForClassFields : false ,
31
- } ,
32
- keepClassNames : true ,
33
- baseUrl : tsOptions ?. baseUrl ,
34
- paths : tsOptions ?. paths ,
25
+ transform : {
26
+ legacyDecorator : true ,
27
+ decoratorMetadata : true ,
28
+ useDefineForClassFields : false ,
35
29
} ,
36
- minify : false ,
37
- swcrc : true ,
38
- } ,
39
- cliOptions : {
40
- outDir : tsOptions ?. outDir ? convertPath ( tsOptions . outDir ) : 'dist' ,
41
- filenames : [ configuration ?. sourceRoot ?? 'src' ] ,
42
- sync : false ,
43
- extensions : [ '.js' , '.ts' ] ,
44
- copyFiles : false ,
45
- includeDotfiles : false ,
46
- quiet : false ,
47
- watch : false ,
48
- stripLeadingPaths : true ,
49
- ...builderOptions ,
30
+ keepClassNames : true ,
31
+ baseUrl : tsOptions ?. baseUrl ,
32
+ paths : tsOptions ?. paths ,
50
33
} ,
34
+ minify : false ,
35
+ swcrc : true ,
36
+ } ;
37
+
38
+ // CLI选项
39
+ const cliOptions = {
40
+ outDir : tsOptions ?. outDir ? convertPath ( tsOptions . outDir ) : 'dist' ,
41
+ filenames : [ configuration ?. sourceRoot ?? 'src' ] ,
42
+ sync : false ,
43
+ extensions : [ '.js' , '.ts' ] ,
44
+ copyFiles : false ,
45
+ includeDotfiles : false ,
46
+ quiet : false ,
47
+ watch : false ,
48
+ stripLeadingPaths : true ,
49
+ ...builderOptions ,
50
+ } ;
51
+
52
+ return {
53
+ swcOptions,
54
+ cliOptions,
51
55
} ;
52
56
} ;
53
57
0 commit comments