Skip to content

Commit

Permalink
feat: remove Builder keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin committed Sep 12, 2024
1 parent 7c46ca3 commit 6b69b72
Show file tree
Hide file tree
Showing 35 changed files with 55 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: convertToRem
- **Type:** `boolean | object`
- **Default:** `false`

By setting `output.convertToRem`, the Builder can do the following things:
By setting `output.convertToRem`, Modern.js can do the following things:

- Convert px to rem in CSS.
- Insert runtime code into the HTML template to set the fontSize of the root element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title: disableTsChecker

Whether to disable TypeScript type checker during compilation.

By default, Modern.js will run the TypeScript type checker in a separate process during the build process. Its checking logic is consistent with TypeScript's native `tsc` command. You can use `tsconfig.json` or Builder's `tools.tsChecker` config to customize the checking behavior.
By default, Modern.js will run the TypeScript type checker in a separate process during the build process. Its checking logic is consistent with TypeScript's native `tsc` command. You can use `tsconfig.json` or `tools.tsChecker` config to customize the checking behavior.

### Blocking Compilation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const defaultBuildCacheConfig = {

- **Bundler:** `only support webpack`

Controls the Builder's caching behavior during the build process.
Controls the caching behavior during the build process.

Modern.js will enable build cache by default to improve the compile speed, the generated cache files are write to the `./node_modules/.cache/webpack` directory by default.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ configName: performance.bundleAnalyze

Used to enable the [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) plugin to analyze the size of the output.

By default, Builder does not enable `webpack-bundle-analyzer`. When this feature is enabled, the default configuration is as follows:
By default, Modern.js does not enable `webpack-bundle-analyzer`. When this feature is enabled, the default configuration is as follows:

```js
const defaultConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type TransformImport =

- **Default:**

When the [Ant Design component library](https://www.npmjs.com/package/antd) <= 4.x version is installed in the project, Builder will automatically add the following default configurations:
When the [Ant Design component library](https://www.npmjs.com/package/antd) <= 4.x version is installed in the project, Modern.js will automatically add the following default configurations:

```js
const defaultAntdConfig = {
Expand All @@ -36,7 +36,7 @@ const defaultAntdConfig = {
};
```

When the [Arco Design component library](https://www.npmjs.com/package/@arco-design/web-react) is installed in the project, Builder will automatically add the following default configurations:
When the [Arco Design component library](https://www.npmjs.com/package/@arco-design/web-react) is installed in the project, Modern.js will automatically add the following default configurations:

```js
const defaultArcoConfig = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ With `tools.babel` you can modify the options of [babel-loader](https://github.c
Please note the limitations of `tools.babel` in the following usage scenarios:

- Rspack scenario: When using Rspack as the bundler, using the `tools.babel` option will significantly slow down the Rspack's build speed. This is because Rspack defaults to using SWC for compilation, and configuring Babel will cause the code to be compiled twice, resulting in additional compilation overhead.
- webpack + SWC scenario: When using webpack as the bundler, if you use Builder's SWC plugin for code compilation, the `tools.babel` option will not take effect.
- webpack + SWC scenario: When using webpack as the bundler, if you use SWC plugin for code compilation, the `tools.babel` option will not take effect.

### Function Type

Expand Down Expand Up @@ -42,7 +42,7 @@ export default {
The second parameter of the `tools.babel` function provides some more convenient utility functions. Please continue reading the documentation below.

:::tip
The above example is just for reference, usually you don't need to manually configure `babel-plugin-import`, because the Builder already provides a more general `source.transformImport` configuration.
The above example is just for reference, usually you don't need to manually configure `babel-plugin-import`, because Modern.js already provides a more general `source.transformImport` configuration.
:::

### Object Type
Expand Down Expand Up @@ -210,7 +210,7 @@ Deprecated, please use [source.exclude](https://modernjs.dev/en/configure/app/so

### Debugging Babel Configuration

After modifying the `babel-loader` configuration through `tools.babel`, you can view the final generated configuration in [Builder debug mode](https://rsbuild.dev/guide/debug/debug-mode).
After modifying the `babel-loader` configuration through `tools.babel`, you can view the final generated configuration in [Rsbuild debug mode](https://rsbuild.dev/guide/debug/debug-mode).

First, enable debug mode by using the `DEBUG=builder` parameter:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default {

### Modifying Less Version

In some scenarios, if you need to use a specific version of Less instead of the built-in Less v4 in Builder, you can install the desired Less version in your project and set it up using the `implementation` option of the `less-loader`.
In some scenarios, if you need to use a specific version of Less instead of the built-in Less v4 in Modern.js, you can install the desired Less version in your project and set it up using the `implementation` option of the `less-loader`.

```js
export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {

### Modifying Sass Version

In some scenarios, if you need to use a specific version of Sass instead of the built-in Dart Sass v1 in Builder, you can install the desired Sass version in your project and set it up using the `implementation` option of the `sass-loader`.
In some scenarios, if you need to use a specific version of Sass instead of the built-in Dart Sass v1 in Modern.js, you can install the desired Sass version in your project and set it up using the `implementation` option of the `sass-loader`.

```js
export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default {

#### CHAIN_ID

Some common Chain IDs are predefined in the Builder, and you can use these IDs to locate the built-in Rule or Plugin.
Some common Chain IDs are predefined in the Modern.js, and you can use these IDs to locate the built-in Rule or Plugin.

:::tip
Please note that some of the rules or plugins listed below are not available by default. They will only be included in the webpack configuration when you enable specific options or register certain plugins.
Expand Down Expand Up @@ -227,8 +227,8 @@ For example, the `RULE.STYLUS` rule exists only when the Stylus plugin is regist
| `PLUGIN.REACT_FAST_REFRESH` | correspond to `ReactFastRefreshPlugin` |
| `PLUGIN.NODE_POLYFILL_PROVIDE` | correspond to `ProvidePlugin` for node polyfills |
| `PLUGIN.SUBRESOURCE_INTEGRITY` | correspond to `webpack-subresource-integrity` |
| `PLUGIN.ASSETS_RETRY` | correspond to webpack static asset retry plugin in Builder |
| `PLUGIN.AUTO_SET_ROOT_SIZE` | correspond to automatically set root font size plugin in Builder |
| `PLUGIN.ASSETS_RETRY` | correspond to webpack static asset retry plugin |
| `PLUGIN.AUTO_SET_ROOT_SIZE` | correspond to automatically set root font size plugin |

#### CHAIN_ID.MINIMIZER

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[CSS Modules](https://github.com/css-modules/css-modules) allows us to write CSS code in a modular way, and these styles can be imported and used in JavaScript files. Using CSS Modules can automatically generate unique class names, isolate styles between different modules, and avoid class name conflicts.

Builder supports CSS Modules by default, you don't need to add additional configuration. Our convention is to use the `[name].module.css` filename to enable CSS Modules.
Modern.js supports CSS Modules by default, you don't need to add additional configuration. Our convention is to use the `[name].module.css` filename to enable CSS Modules.

The following style files are considered CSS Modules:

Expand Down Expand Up @@ -163,7 +163,7 @@ After adding the type declaration, if the type error still exists, you can try t

Although the above method can provide the type of CSS Modules, it cannot accurately prompt which classNames are exported by a certain CSS file.

Builder supports generating accurate type declarations for CSS Modules, you only need to enable the [output.enableCssModuleTSDeclaration](/configure/app/output/enable-css-module-tsdeclaration) config, and then execute the build, Modern.js will generate type declaration files for all CSS Modules.
Modern.js supports generating accurate type declarations for CSS Modules, you only need to enable the [output.enableCssModuleTSDeclaration](/configure/app/output/enable-css-module-tsdeclaration) config, and then execute the build, Modern.js will generate type declaration files for all CSS Modules.

```ts
export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ In the filename, `[name]` represents the entry name corresponding to this file,

## Modify the Directory

Builder provides some configs to modify the directory or filename, you can:
Modern.js provides some configs to modify the directory or filename, you can:

- Modify the filename through [output.filename](/configure/app/output/filename).
- Modify the output path of through [output.distPath](/configure/app/output/dist-path).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 2

# Build Engine

Modern.js internally encapsulates its own build tool (Modern.js Builder) based on [Rsbuild](https://rsbuild.dev/), and supports seamless switching between Webpack and Rspack bundlers.
Modern.js internally encapsulates [Rsbuild](https://rsbuild.dev/), and supports seamless switching between Webpack and Rspack bundlers.

::: tip What is Rsbuild?
Rsbuild is a build tool based on Rspack. It is an enhanced Rspack CLI, easy-to-use, and ready-to-use out of the box.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Modern.js provides [inspect command](https://modernjs.dev/en/apis/app/commands.h

Inspect config succeed, open following files to view the content:

- Builder Config: /root/my-project/dist/builder.config.js
- Rspack Config (web): /root/my-project/dist/rspack.config.web.js
- Builder Config: /root/my-project/dist/rsbuild.config.mjs
- Rspack Config (web): /root/my-project/dist/rspack.config.web.mjs
```

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ For a detailed comparison between minifiers, see [minification-benchmarks](https

### Used in Modern.js framework

The Modern.js framework integrates the Builder's SWC plugin, and you can use it in the following ways:
The Modern.js framework integrates the SWC plugin, and you can use it in the following ways:

import EnableSWC from '@site-docs-en/components/enableSwc.mdx';

Expand Down Expand Up @@ -297,7 +297,7 @@ This is ported by Next.js team from [@emotion/babel-plugin](https://www.npmjs.co
#### extensions.pluginImport

:::tip
Builder provides the [source.transformImport](/configure/app/source/transform-import) config, so you don't need to configure `extensions.pluginImport` manually.
Modern.js provides the [source.transformImport](/configure/app/source/transform-import) config, so you don't need to configure `extensions.pluginImport` manually.
:::

Ported from [babel-plugin-import](https://github.com/umijs/babel-plugin-import), configurations are the same.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Esbuild from '@site-docs-en/components/esbuild.mdx';

### Used in Modern.js framework

The Modern.js framework integrates the Builder's esbuild plugin by default, so you don't need to manually install and register the plugin, just use the [tools.esbuild](https://modernjs.dev/en/configure/app/tools/esbuild.html) configuration:
The Modern.js framework integrates the esbuild plugin by default, so you don't need to manually install and register the plugin, just use the [tools.esbuild](https://modernjs.dev/en/configure/app/tools/esbuild.html) configuration:

```js
export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion packages/document/main-doc/docs/zh/components/builder.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Modern.js Builder 指的是 Modern.js 的构建层,它的目标是为 Modern.js 用户提供开箱即用的构建能力,并支持在 webpack 和 Rspack 间无缝切换。
Builder 指的是 Modern.js 的构建层,它的目标是为 Modern.js 用户提供开箱即用的构建能力,并支持在 webpack 和 Rspack 间无缝切换。

Modern.js `MAJOR_VERSION.46.0` 之前版本使用的是 `@modern-js/builder`, 从 `MAJOR_VERSION.46.0` 开始升级为 [Rsbuild](https://rsbuild.dev/)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: convertToRem
- **类型:** `boolean | object`
- **默认值:** `false`

通过设置 `output.convertToRem`Builder 可进行如下处理:
通过设置 `output.convertToRem`Modern.js 可进行如下处理:

- 将 CSS 中的 px 转成 rem
- 在 HTML 模版中插入运行时代码,对根元素 fontSize 进行设置
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ title: disableInlineRuntimeChunk
用于控制是否将打包工具的 runtime 代码内联到 HTML 中。

:::tip 什么是 runtimeChunk
当 Builder 构建完成后,会在 dist 目录生成 `builder-runtime.js` 文件,该文件为 webpack 或 Rspack 的 runtime 代码,即 runtimeChunk。
当构建完成后,会在 dist 目录生成 `builder-runtime.js` 文件,该文件为 webpack 或 Rspack 的 runtime 代码,即 runtimeChunk。

runtimeChunk 是一段运行时代码,它由 webpack 或 Rspack 提供,包含必要的模块处理逻辑,比如模块加载、模块解析等,具体可参考 [Runtime](https://webpack.js.org/concepts/manifest/#runtime)

:::

在生产环境下,Builder 默认会将 runtimeChunk 文件内联到 HTML 文件中,而不是写到产物目录中,这样做是为了减少文件请求的数量。
在生产环境下,Modern.js 默认会将 runtimeChunk 文件内联到 HTML 文件中,而不是写到产物目录中,这样做是为了减少文件请求的数量。

### 禁用内联

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title: disableTsChecker

是否禁用编译过程中的 TypeScript 类型检查。

默认情况下,Builder 执行构建的过程中,会在一个独立的进程里运行 TypeScript 类型检查工具,它的检查逻辑与 TypeScript 原生的 `tsc` 命令一致,你可以通过 `tsconfig.json` 或是 Builder 的 `tools.tsChecker` 配置项来自定义检查行为。
默认情况下,Modern.js 执行构建的过程中,会在一个独立的进程里运行 TypeScript 类型检查工具,它的检查逻辑与 TypeScript 原生的 `tsc` 命令一致,你可以通过 `tsconfig.json` `tools.tsChecker` 配置项来自定义检查行为。

### 阻塞编译

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const defaultBuildCacheConfig = {

- **打包工具:** `仅支持 webpack`

控制 Builder 在构建过程中的缓存行为。
控制 Modern.js 在构建过程中的缓存行为。

Builder 默认会开启构建缓存来提升二次构建的速度,并默认把生成的缓存文件写到 `./node_modules/.cache/webpack` 目录下。
Modern.js 默认会开启构建缓存来提升二次构建的速度,并默认把生成的缓存文件写到 `./node_modules/.cache/webpack` 目录下。

你可以通过 `buildCache` 配置缓存路径,比如:

Expand All @@ -59,7 +59,7 @@ export default {

### cacheDigest

`cacheDigest` 用来添加一些会对构建结果产生影响的环境变量。Builder 将根据 `cacheDigest` 内容和当前构建模式来设置缓存名称,来确保不同的 `cacheDigest` 可以命中不同的缓存。
`cacheDigest` 用来添加一些会对构建结果产生影响的环境变量。Modern.js 将根据 `cacheDigest` 内容和当前构建模式来设置缓存名称,来确保不同的 `cacheDigest` 可以命中不同的缓存。

#### 示例

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ configName: performance.bundleAnalyze

用于开启 [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) 插件来分析产物体积。

默认情况下,Builder 不会开启 `webpack-bundle-analyzer`。当开启该功能后,内部的默认配置如下:
默认情况下,Modern.js 不会开启 `webpack-bundle-analyzer`。当开启该功能后,内部的默认配置如下:

```js
const defaultConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ title: globalVars
- **默认值:**

```ts
// Builder 默认会添加环境变量 `process.env.NODE_ENV`,因此你不需要手动添加它。
// Modern.js 默认会添加环境变量 `process.env.NODE_ENV`,因此你不需要手动添加它。
const defaultGlobalVars = {
'process.env.NODE_ENV': process.env.NODE_ENV,
};
Expand Down Expand Up @@ -100,7 +100,7 @@ export default {

`source.globalVars` 是通过字符串替换的形式来注入环境变量的,因此它无法对「解构赋值」等动态写法生效。

在使用解构赋值时,Builder 将无法判断变量 `NODE_ENV` 是否与要替换的表达式 `process.env.NODE_ENV` 存在关联,因此以下使用方式是无效的:
在使用解构赋值时,Modern.js 将无法判断变量 `NODE_ENV` 是否与要替换的表达式 `process.env.NODE_ENV` 存在关联,因此以下使用方式是无效的:

```js
const { NODE_ENV } = process.env;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type TransformImport =

- **默认值:**

当项目中安装了 [Ant Design 组件库](https://www.npmjs.com/package/antd) <= 4.x 版本时,Builder 会自动添加以下默认配置:
当项目中安装了 [Ant Design 组件库](https://www.npmjs.com/package/antd) <= 4.x 版本时,Modern.js 会自动添加以下默认配置:

```js
const defaultAntdConfig = {
Expand All @@ -36,7 +36,7 @@ const defaultAntdConfig = {
};
```

当项目中安装了 [Arco Design 组件库](https://www.npmjs.com/package/@arco-design/web-react) 时,Builder 会自动添加以下默认配置:
当项目中安装了 [Arco Design 组件库](https://www.npmjs.com/package/@arco-design/web-react) 时,Modern.js 会自动添加以下默认配置:

```js
const defaultArcoConfig = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ title: babel
请留意 `tools.babel` 在以下使用场景中的局限性:

- Rspack 场景:在使用 Rspack 作为打包工具时,使用 `tools.babel` 配置项将会明显拖慢 Rspack 构建速度。因为 Rspack 默认使用的是 SWC 编译,配置 Babel 会导致代码需要被编译两次,产生了额外的编译开销。
- webpack + SWC 场景:在使用 webpack 作为打包工具时,如果你使用了 Builder 的 SWC 插件进行代码编译,那么 `tools.babel` 选项将不会生效。
- webpack + SWC 场景:在使用 webpack 作为打包工具时,如果你使用了 SWC 插件进行代码编译,那么 `tools.babel` 选项将不会生效。

### Function 类型

Expand All @@ -41,7 +41,7 @@ export default {
`tools.babel` 函数的第二个参数提供了一些方便的工具函数,请继续阅读下方文档。

:::tip
以上示例仅作为参考,通常来说,你不需要手动配置 `babel-plugin-import`,因为 Builder 已经提供了更通用的 `source.transformImport` 配置。
以上示例仅作为参考,通常来说,你不需要手动配置 `babel-plugin-import`,因为 Modern.js 已经提供了更通用的 `source.transformImport` 配置。
:::

### Object 类型
Expand Down Expand Up @@ -209,7 +209,7 @@ export default {

### 调试 Babel 配置

当你通过 `tools.babel` 修改 `babel-loader` 配置后,可以在 [Builder 调试模式](https://rsbuild.dev/zh/guide/debug/debug-mode) 下查看最终生成的配置。
当你通过 `tools.babel` 修改 `babel-loader` 配置后,可以在 [调试模式](https://rsbuild.dev/zh/guide/debug/debug-mode) 下查看最终生成的配置。

首先通过 `DEBUG=builder` 参数开启调试模式:

Expand Down
Loading

0 comments on commit 6b69b72

Please sign in to comment.