chore: use swc instead of esbuild (#359)

使用 swc 代替 esbuild,之前在 https://github.com/halo-dev/docs/pull/358 中引入了 esbuild,但发现在生产构建之后会出现这个问题:

<img width="1912" alt="image" src="https://github.com/halo-dev/docs/assets/21301288/5dcd724d-3876-4e58-b902-1818dd9d1fbd">

暂时不清楚为什么,使用 swc 测试构建之后没有这个问题。

/kind bug

```release-note
None
```
This commit is contained in:
Ryan Wang
2024-05-28 13:18:58 +08:00
committed by GitHub
parent ac0b158b73
commit d78a16e217
3 changed files with 277 additions and 419 deletions

View File

@@ -256,11 +256,18 @@ const config = {
],
webpack: {
jsLoader: (isServer) => ({
loader: require.resolve('esbuild-loader'),
loader: require.resolve("swc-loader"),
options: {
loader: 'tsx',
format: isServer ? 'cjs' : undefined,
target: isServer ? 'node12' : 'es2017',
jsc: {
parser: {
syntax: "typescript",
tsx: true,
},
target: "es2017",
},
module: {
type: isServer ? "commonjs" : "es6",
},
},
}),
},