Skip to content

Commit 12a612e

Browse files
liaoyuliaoxiaoyou
andauthored
swc support (#167)
* feat: init swc * feat: swc integrate * fix: compat mobx * fix: compat browserslist * fix: detect babel options * fix: check swc should enabled * fix: add shippedProposals * fix: convert tsconfig.json to swc config * fix: fix review & update builder-config.md Co-authored-by: liaoxiaoyou <liaoxiaoyou@youzan.com>
1 parent 5a03a30 commit 12a612e

File tree

9 files changed

+674
-202
lines changed

9 files changed

+674
-202
lines changed

build-config.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,26 @@ const apiUrl = "http://foobar.com/api" + 'test'
320320

321321
`true` 表示开启,`false` 表示关闭,默认开启。
322322

323+
- **`optimization.swc`**
324+
325+
类型:`boolean`
326+
327+
是否使用 `swc` 替换 `babel-loader``ts-loader`,开启 `swc` 时需注意以下几点:
328+
329+
* 如果自定义 `transforms` 的配置中包含 `babelOptions``swc` 将不会开启
330+
331+
* `swc` 不会读取项目中的 `tsconfig.json` 配置,`fec-builder` 会将 `tsconfig.json` [部分的 `compilerOptions` 配置](https://github.com/Front-End-Engineering-Cloud/builder/pull/167/commits/1679c2ba46c7c2e5babdd9fb29c1202dce8a6da9#diff-83d272b0300573209dc5e33e57e9ac300c837e0327f36ea67cef9a685a06becbR25) 转换后传给 `swc`
332+
333+
* `swc` 不支持 `ts` 的类型检查,导致 `transpileOnlyWhenDev` 开关无效,如果需要在打包中校验类型可在打包构建步骤中加入 `tsc --noEmit` 来做类型检查
334+
335+
* `swc` 不支持使用项目中 `typescript` 进行编译,导致 `useProjectTypeScript` 开关无效
336+
337+
* `swc` 不支持 `JSX` 中的 `spread operator` 语法
338+
339+
* `browserslist``swc` 中的行为相较 `babel` 有所差异,以配置的 `extends @qiniu/build-config/portal` 为例,使用 `swc``bundle` 中会包含 `let` `const` `async` `await` `箭头函数` 语法
340+
341+
`true` 表示开启,`false` 表示关闭,默认关闭。
342+
323343
## **`devProxy`**
324344

325345
类型:`object`

0 commit comments

Comments
 (0)