Skip to content

Commit

Permalink
docs: fix the documentation of source build error (#6476)
Browse files Browse the repository at this point in the history
  • Loading branch information
easy1090 authored Nov 1, 2024
1 parent d8d5679 commit 64ada6b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-ravens-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modern-js/main-doc': patch
---

chore(docs): fix the documentation of source build error
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,10 @@ Project reference provides the following capabilities:

### Example

In the example mentioned earlier, since the app project references the lib sub-project, we need to configure the `composite` and `references` options in the app project's `tsconfig.json` file and point them to the corresponding relative directory of lib:
In the example mentioned earlier, since the app project references the lib sub-project, we need to configure the `references` options in the app project's `tsconfig.json` to point to the relative directory of the lib:

```json title="app/tsconfig.json"
{
"compilerOptions": {
"composite": true
},
"references": [
{
"path": "../lib"
Expand All @@ -139,6 +136,16 @@ In the example mentioned earlier, since the app project references the lib sub-p
}
```

At the same time, we need to set `composite` to `true` in the lib project's `tsconfig.json`:

```json title="lib/A/tsconfig.json"
{
"compilerOptions": {
"composite": true
},
}
```

After adding these two options, the project reference is already configured. You can restart VS Code to see the effects of the configuration.

Note that the above example is a simplified one. In real monorepo projects, there may be more complex dependency relationships. You need to add a complete `references` configuration for the functionality to work correctly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,10 @@ Project reference 提供了以下能力:

### 示例

在上文的例子中,由于 app 引用了 lib 子项目,我们需要在 app 的 `tsconfig.json` 内配置 `composite``references`,并指向 lib 对应的相对目录:
在上文的例子中,由于 app 引用了 lib 子项目,我们需要在 app 的 `tsconfig.json` 内配置 `references`,并指向 lib 对应的相对目录:

```json title="app/tsconfig.json"
{
"compilerOptions": {
"composite": true
},
"references": [
{
"path": "../lib"
Expand All @@ -139,6 +136,16 @@ Project reference 提供了以下能力:
}
```

同时,需要在 lib 子项目的 `tsconfig.json` 内配置 `composite``true`

```json title="lib/A/tsconfig.json"
{
"compilerOptions": {
"composite": true
},
}
```

添加以上两个选项后,project reference 就已经配置完成了,你可以重新启动 VS Code 来查看配置以后的效果。

注意以上只是一个最简单的例子,在实际的 monorepo 项目中,可能会有更复杂的依赖关系,你需要添加完整的 `references` 配置,才能使上述功能正确运作。
Expand Down
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 64ada6b

Please sign in to comment.