You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-6Lines changed: 18 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,18 @@ If the sub-project uses [exports](https://nodejs.org/api/packages.html#package-e
122
122
}
123
123
```
124
124
125
+
### Customizing Source Field
126
+
127
+
Although the plugin uses the `source` field by default to specify the source file, we recommend configuring a custom field through the [sourceField](#sourceField) option (for example, `@custom/source`, where `custom` can be replaced with any scope name).
128
+
129
+
```ts
130
+
pluginSourceBuild({
131
+
sourceField: "@custom/source",
132
+
});
133
+
```
134
+
135
+
This is because some packages (such as Mobx) also define a `source` field in their `package.json`. If not distinguished, Rsbuild may mistakenly resolve the source files of those dependencies, leading to unexpected build results or type issues. By using a custom field, you can avoid such conflicts and ensure that Rsbuild behaves predictably when resolving dependencies.
136
+
125
137
## Configure Project Reference
126
138
127
139
In a TypeScript project, you need to use the capability provided by TypeScript called [Project Reference](https://typescriptlang.org/docs/handbook/project-references). It helps you develop source code more effectively.
@@ -154,7 +166,7 @@ At the same time, we need to set `composite` to `true` in the lib project's `tsc
154
166
{
155
167
"compilerOptions": {
156
168
"composite": true
157
-
},
169
+
}
158
170
}
159
171
```
160
172
@@ -173,24 +185,24 @@ Note that the above example is a simplified one. In real monorepo projects, ther
173
185
174
186
Used to configure the resolve field of the source code files.
175
187
176
-
For example, when configured as `my-source`:
188
+
For example, when configured as `@custom/source`:
177
189
178
190
```ts
179
191
pluginSourceBuild({
180
-
sourceField: "my-source",
192
+
sourceField: "@custom/source",
181
193
});
182
194
```
183
195
184
-
In `package.json`, the source code file path can be specified using `my-source`:
196
+
In `package.json`, the source code file path can be specified using `@custom/source`:
0 commit comments