Skip to content

Commit

Permalink
docs: use --experimental-transform-types load tsconfig (web-infra-dev…
Browse files Browse the repository at this point in the history
…#7667)

* docs: use --experimental-transform-types load tsconfig

* Update website/docs/zh/config/index.mdx

Co-authored-by: neverland <[email protected]>

* Update website/docs/en/config/index.mdx

Co-authored-by: neverland <[email protected]>

---------

Co-authored-by: neverland <[email protected]>
  • Loading branch information
hardfist and chenjiahan authored Aug 23, 2024
1 parent 0303c68 commit 36df3c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions website/docs/en/config/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ You need to install `ts-node` as `devDependencies` so that Rspack can resolve th
}
```

If the version of Node.js you are using supports the [--experimental-transform-types](https://nodejs.org/api/cli.html#--experimental-transform-types) flag, you can use the built-in TS transformation of Node.js without needing to install `ts-node`.

```json title="package.json"
{
"build": "NODE_OPTIONS=--experimental-transform-types rspack build"
}
```

Note that Rspack will first search JavaScript and then TypeScript if the JS file does not exist.

## Specify the Configuration File
Expand Down
8 changes: 8 additions & 0 deletions website/docs/zh/config/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export = config;
}
```

如果你使用的 Node.js 版本支持 [--experimental-transform-types](https://nodejs.org/api/cli.html#--experimental-transform-types) 功能,那么可以使用 Node.js 内置的 TS 解析功能,而不需要安装 `ts-node`

```json title="package.json"
{
"build": "NODE_OPTIONS=--experimental-transform-types rspack build"
}
```

注意,如果 JS 文件不存在,Rspack 将首先搜索 JavaScript,然后才是 TypeScript。

## 指定配置文件
Expand Down

0 comments on commit 36df3c2

Please sign in to comment.