> For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt.

# experiments.sourceBuild

- **类型：** `boolean | PluginSourceBuildOptions`
- **默认值：** `false`

用于开启源码构建的能力。当开启此配置项时，Modern.js 会读取子项目 package.json 的 `source` 字段对应的源码文件，并进行编译。

```ts
export default {
  experiments: {
    sourceBuild: true,
  },
};
```

更多信息可参考[「源码构建模式」](https://modernjs.dev/guides/advanced-features/source-build.html)。

### 选项

`experiments.sourceBuild` 底层基于 [@rsbuild/plugin-source-build](https://github.com/rstackjs/rsbuild-plugin-source-build?tab=readme-ov-file#options) 实现，你可以传入插件选项，比如：

```ts
export default {
  experiments: {
    sourceBuild: {
      sourceField: 'my-source',
      resolvePriority: 'output',
    },
  },
};
```
