Skip to content

Commit

Permalink
swc support (#167)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
liaoyu and liaoxiaoyou authored Nov 24, 2022
1 parent 5a03a30 commit 12a612e
Show file tree
Hide file tree
Showing 9 changed files with 674 additions and 202 deletions.
20 changes: 20 additions & 0 deletions build-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,26 @@ const apiUrl = "http://foobar.com/api" + 'test'

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

- **`optimization.swc`**

类型:`boolean`

是否使用 `swc` 替换 `babel-loader``ts-loader`,开启 `swc` 时需注意以下几点:

* 如果自定义 `transforms` 的配置中包含 `babelOptions``swc` 将不会开启

* `swc` 不会读取项目中的 `tsconfig.json` 配置,`fec-builder` 会将 `tsconfig.json` [部分的 `compilerOptions` 配置](https://github.com/Front-End-Engineering-Cloud/builder/pull/167/commits/1679c2ba46c7c2e5babdd9fb29c1202dce8a6da9#diff-83d272b0300573209dc5e33e57e9ac300c837e0327f36ea67cef9a685a06becbR25) 转换后传给 `swc`

* `swc` 不支持 `ts` 的类型检查,导致 `transpileOnlyWhenDev` 开关无效,如果需要在打包中校验类型可在打包构建步骤中加入 `tsc --noEmit` 来做类型检查

* `swc` 不支持使用项目中 `typescript` 进行编译,导致 `useProjectTypeScript` 开关无效

* `swc` 不支持 `JSX` 中的 `spread operator` 语法

* `browserslist``swc` 中的行为相较 `babel` 有所差异,以配置的 `extends @qiniu/build-config/portal` 为例,使用 `swc``bundle` 中会包含 `let` `const` `async` `await` `箭头函数` 语法

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

## **`devProxy`**

类型:`object`
Expand Down
Loading

0 comments on commit 12a612e

Please sign in to comment.