Skip to content

Commit 4cf229c

Browse files
author
bangyu.xiangby
committed
feat: 再次优化代码
1 parent f938146 commit 4cf229c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/compiler/defaults/swc-defaults.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ export const swcDefaultsFactory = (
1111
? configuration.compilerOptions.builder.options
1212
: {};
1313

14-
// SWC编译器选项
14+
// Define SWC compiler options with sensible defaults
1515
const swcOptions = {
16+
// Enable source maps based on TypeScript config
1617
sourceMaps: tsOptions?.sourceMap || (tsOptions?.inlineSourceMap && 'inline'),
1718
module: { type: 'commonjs' },
1819
jsc: {
19-
target: 'es2021',
20+
// Use modern ES2021 target for better performance
21+
target: 'es2021',
2022
parser: {
2123
syntax: 'typescript',
2224
decorators: true,
@@ -28,24 +30,29 @@ export const swcDefaultsFactory = (
2830
useDefineForClassFields: false,
2931
},
3032
keepClassNames: true,
33+
// Preserve TypeScript path mappings
3134
baseUrl: tsOptions?.baseUrl,
3235
paths: tsOptions?.paths,
3336
},
3437
minify: false,
3538
swcrc: true,
3639
};
3740

38-
// CLI选项
41+
// CLI build configuration
3942
const cliOptions = {
43+
// Use TypeScript outDir or default to 'dist'
4044
outDir: tsOptions?.outDir ? convertPath(tsOptions.outDir) : 'dist',
45+
// Source files location with fallback
4146
filenames: [configuration?.sourceRoot ?? 'src'],
47+
// Default CLI behavior
4248
sync: false,
43-
extensions: ['.js', '.ts'],
49+
extensions: ['.js', '.ts', '.tsx'],
4450
copyFiles: false,
4551
includeDotfiles: false,
4652
quiet: false,
4753
watch: false,
4854
stripLeadingPaths: true,
55+
// Override defaults with any builder options
4956
...builderOptions,
5057
};
5158

0 commit comments

Comments
 (0)