-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add announcing Rsbuild v0.4 (#1520)
- Loading branch information
1 parent
5ea0347
commit 7e979aa
Showing
4 changed files
with
298 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
["index", "v0-3", "v0-2", "v0-1"] | ||
["index", "v0-4", "v0-3", "v0-2", "v0-1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# Announcing Rsbuild v0.4 | ||
|
||
> February 06, 2024 | ||
![](https://lf3-static.bytednsdoc.com/obj/eden-cn/rjhwzy/ljhwZthlaukjlkulzlp/rsbuild/Rsbuild-v0-4.png) | ||
|
||
Rsbuild v0.4 provides built-in support for module federation. It also contains some incompatible API updates. Please refer to the current document for upgrading. | ||
|
||
### Module Federation Config | ||
|
||
Rsbuild now provides a builtin [moduleFederation](/config/module-federation/options) option, which will make configuring Module Federation in Rsbuild much easier. | ||
|
||
- **Example:** | ||
|
||
```ts title="rsbuild.config.ts" | ||
export default defineConfig({ | ||
moduleFederation: { | ||
options: { | ||
// ModuleFederationPluginOptions | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
When you use this option, Rsbuild will automatically set the default `publicPath` and `splitChunks` config, making module federation ready to use out of the box. | ||
|
||
> See [RFC - Provide first-class support for Module Federation](https://github.com/web-infra-dev/rsbuild/discussions/1461) for details. | ||
### Plugin Hook Order | ||
|
||
In Rsbuild plugin, you can now declare the order of hooks using the `order` field: | ||
|
||
```ts | ||
const myPlugin = () => ({ | ||
setup: (api) => { | ||
api.modifyRsbuildConfig({ | ||
handler: () => console.log('hello'), | ||
order: 'pre', | ||
}); | ||
}, | ||
}); | ||
``` | ||
|
||
> For more details, see [Plugin Hooks](/plugins/dev/hooks). | ||
### Rename disableFilenameHash | ||
|
||
The `output.disableFilenameHash` config has been renamed to [output.filenameHash](/config/output/filename-hash). | ||
|
||
- Before: | ||
|
||
```ts | ||
export default { | ||
output: { | ||
disableFilenameHash: true, | ||
}, | ||
}; | ||
``` | ||
|
||
- After: | ||
|
||
```ts | ||
export default { | ||
output: { | ||
filenameHash: false, | ||
}, | ||
}; | ||
``` | ||
|
||
## Remove postcss-flexbugs-fixes | ||
|
||
Rsbuild v0.4 removed the builtin [postcss-flexbugs-fixes](https://github.com/luisrudge/postcss-flexbugs-fixes) plugin. | ||
|
||
This plugin is used to fix some flex bugs for IE 10 / 11. Considering that modern browsers no longer have these flex issues, we removed this plugin to improve build performance. | ||
|
||
If your project needs to be compatible with IE 10 / 11 and encounters these flex issues, you can manually add this plugin in Rsbuild: | ||
|
||
- Install plugin: | ||
|
||
```bash | ||
npm add postcss-flexbugs-fixes -D | ||
``` | ||
|
||
- Register plugin in `postcss.config.cjs`: | ||
|
||
```js | ||
module.exports = { | ||
'postcss-flexbugs-fixes': {}, | ||
}; | ||
``` | ||
|
||
## Pure React Plugin | ||
|
||
The React plugin has removed default [source.transformImport](/config/source/transform-import) config for [antd](https://www.npmjs.com/package/antd) v4 and [@arco-design/web-react](https://www.npmjs.com/package/@arco-design/web-react). | ||
|
||
Configurations related to the UI library should be provided in the UI library-specific plugins, such as `rsbuild-plugin-antd` or `rsbuild-plugin-arco`, and the React plugin will concentrate on providing fundamental abilities for React. | ||
|
||
- If your project is using `antd` v3 or v4, you can manually add the following config: | ||
|
||
```ts title="rsbuild.config.ts" | ||
export default { | ||
source: { | ||
transformImport: [ | ||
{ | ||
libraryName: 'antd', | ||
libraryDirectory: 'es', | ||
style: true, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
|
||
- If your project is using `@arco-design/web-react`, you can manually add the following config: | ||
|
||
```ts title="rsbuild.config.ts" | ||
export default { | ||
source: { | ||
transformImport: [ | ||
{ | ||
libraryName: '@arco-design/web-react', | ||
libraryDirectory: 'es', | ||
camelToDashComponentName: false, | ||
style: true, | ||
}, | ||
{ | ||
libraryName: '@arco-design/web-react/icon', | ||
libraryDirectory: 'react-icon', | ||
camelToDashComponentName: false, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
|
||
## JavaScript API | ||
|
||
The `loadConfig` method now returns both the contents of the config and the path to the config file: | ||
|
||
```js | ||
import { loadConfig } from '@rsbuild/core'; | ||
|
||
// v0.3 | ||
const config = await loadConfig(); | ||
|
||
// v0.4 | ||
const { content, filePath } = await loadConfig(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
["index", "v0-3", "v0-2", "v0-1"] | ||
["index", "v0-4", "v0-3", "v0-2", "v0-1"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
# Rsbuild v0.4 发布 | ||
|
||
> February 06, 2024 | ||
![](https://lf3-static.bytednsdoc.com/obj/eden-cn/rjhwzy/ljhwZthlaukjlkulzlp/rsbuild/Rsbuild-v0-4.png) | ||
|
||
Rsbuild v0.4 版本提供内置的模块联邦支持。此外,还包含一些 API 的不兼容更新,请参考当前文档进行升级。 | ||
|
||
### 模块联邦配置 | ||
|
||
Rsbuild 现在提供一个内置的 [moduleFederation](/config/module-federation/options) 选项,这将使得在 Rsbuild 中配置模块联邦变得更加容易。 | ||
|
||
- **示例:** | ||
|
||
```ts title="rsbuild.config.ts" | ||
export default defineConfig({ | ||
moduleFederation: { | ||
options: { | ||
// ModuleFederationPluginOptions | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
当你使用该选项时,Rsbuild 会自动修改默认的 `publicPath` 和 `splitChunks` 配置,使模块联邦可以开箱即用。 | ||
|
||
> 详见 [RFC - Provide first-class support for Module Federation](https://github.com/web-infra-dev/rsbuild/discussions/1461)。 | ||
### 插件 Hook 顺序 | ||
|
||
在 Rsbuild 插件中使用 hook 时,现在可以通过 `order` 字段来声明 hook 的顺序: | ||
|
||
```ts | ||
const myPlugin = () => ({ | ||
setup: (api) => { | ||
api.modifyRsbuildConfig({ | ||
handler: () => console.log('hello'), | ||
order: 'pre', | ||
}); | ||
}, | ||
}); | ||
``` | ||
|
||
> 详见 [Plugin Hooks](/plugins/dev/hooks)。 | ||
### 重命名 disableFilenameHash | ||
|
||
`output.disableFilenameHash` 配置已被重命名为 [output.filenameHash](/config/output/filename-hash)。 | ||
|
||
- 更改前: | ||
|
||
```ts | ||
export default { | ||
output: { | ||
disableFilenameHash: true, | ||
}, | ||
}; | ||
``` | ||
|
||
- 更改后: | ||
|
||
```ts | ||
export default { | ||
output: { | ||
filenameHash: false, | ||
}, | ||
}; | ||
``` | ||
|
||
## 移除 postcss-flexbugs-fixes | ||
|
||
Rsbuild v0.4 移除了内置的 [postcss-flexbugs-fixes](https://github.com/luisrudge/postcss-flexbugs-fixes) 插件。 | ||
|
||
该插件用于修复 IE 10 / 11 中的一些 flex bug。考虑到现代浏览器已经不再存在这些 flex 问题,我们移除了这个插件以提高构建性能。 | ||
|
||
如果你的项目需要兼容 IE 10 / 11 ,并且遇到了这些 flex 问题,你可以在 Rsbuild 中手动添加这个插件: | ||
|
||
- 安装插件: | ||
|
||
```bash | ||
npm add postcss-flexbugs-fixes -D | ||
``` | ||
|
||
- 在 `postcss.config.cjs` 中注册插件: | ||
|
||
```js | ||
module.exports = { | ||
'postcss-flexbugs-fixes': {}, | ||
}; | ||
``` | ||
|
||
## Pure React 插件 | ||
|
||
React 插件已移除对 [antd](https://www.npmjs.com/package/antd) v4 和 [@arco-design/web-react](https://www.npmjs.com/package/@arco-design/web-react) 的默认 [source.transformImport](/config/source/transform-import) 配置。 | ||
|
||
与组件库相关的配置应该在组件库相关的插件中提供,如 `rsbuild-plugin-antd` 或 `rsbuild-plugin-arco`,而 React 插件会专注于提供 React 基础的能力。 | ||
|
||
- 如果你的项目正在使用 `antd` v3 或 v4,你可以手动添加以下配置: | ||
|
||
```ts title="rsbuild.config.ts" | ||
export default { | ||
source: { | ||
transformImport: [ | ||
{ | ||
libraryName: 'antd', | ||
libraryDirectory: 'es', | ||
style: true, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
|
||
- 如果你的项目正在使用 `@arco-design/web-react` v3 或 v4,你可以手动添加以下配置: | ||
|
||
```ts title="rsbuild.config.ts" | ||
export default { | ||
source: { | ||
transformImport: [ | ||
{ | ||
libraryName: '@arco-design/web-react', | ||
libraryDirectory: 'es', | ||
camelToDashComponentName: false, | ||
style: true, | ||
}, | ||
{ | ||
libraryName: '@arco-design/web-react/icon', | ||
libraryDirectory: 'react-icon', | ||
camelToDashComponentName: false, | ||
}, | ||
], | ||
}, | ||
}; | ||
``` | ||
|
||
## JavaScript API | ||
|
||
`loadConfig` 方法现在会返回配置内容和配置文件的路径: | ||
|
||
```js | ||
import { loadConfig } from '@rsbuild/core'; | ||
|
||
// v0.3 | ||
const config = await loadConfig(); | ||
|
||
// v0.4 | ||
const { content, filePath } = await loadConfig(); | ||
``` |