Skip to content

Commit 9489ce6

Browse files
committed
chore: update
1 parent 87ad101 commit 9489ce6

File tree

5 files changed

+48
-47
lines changed

5 files changed

+48
-47
lines changed

website/docs/zh/config/lib/umd-name.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ UMD 包的模块名称不能与全局变量名称冲突。
1515

1616
UMD 包将会挂载到 `global.MyLibrary`
1717

18-
```ts title="rslib.config.ts" {5}
18+
```ts title="rslib.config.ts"
1919
export default {
2020
lib: [
2121
{
2222
format: 'umd',
23-
umdName: 'MyLibrary',
23+
umdName: 'MyLibrary', // [!code highlight]
2424
},
2525
],
2626
};

website/docs/zh/guide/advanced/json-files.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,19 +240,19 @@ Rslib 支持在不同的打包模式下,JSON / YAML / TOML 文件以不同的
240240

241241
例如下面的配置将会将 `src` 目录下的所有 JSON 文件按原样输出:
242242

243-
```ts title="rslib.config.ts" {7,11-12}
243+
```ts title="rslib.config.ts"
244244
export default defineConfig({
245245
lib: [
246246
{
247247
bundle: false,
248248
source: {
249249
entry: {
250-
index: ['./src/**', '!./src/**/*.json'],
250+
index: ['./src/**', '!./src/**/*.json'], // [!code highlight]
251251
},
252252
},
253253
output: {
254-
copy: [{ from: './**/*.json', context: './src' }],
255-
externals: [/.*\.json$/],
254+
copy: [{ from: './**/*.json', context: './src' }], // [!code highlight]
255+
externals: [/.*\.json$/], // [!code highlight]
256256
},
257257
},
258258
],

website/docs/zh/guide/advanced/module-federation.mdx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ import { PackageManagerTabs } from '@theme';
3030

3131
然后在 `rslib.config.ts` 中注册插件:
3232

33-
```ts title='rslib.config.ts' {8-43}
33+
```ts title='rslib.config.ts'
3434
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
3535
import { pluginReact } from '@rsbuild/plugin-react';
3636
import { defineConfig } from '@rslib/core';
3737

3838
export default defineConfig({
3939
lib: [
4040
// ... 其他 format
41+
// [!code highlight:35]
4142
{
4243
format: 'mf',
4344
output: {
@@ -116,31 +117,31 @@ Rslib 支持宿主应用和 Rslib 模块联邦项目同时开发。
116117
设置宿主应用消费 Rslib 的模块联邦库。查看[@module-federation/rsbuild-plugin
117118
](https://www.npmjs.com/package/@module-federation/rsbuild-plugin) 获取更多信息。
118119

119-
```ts title="rsbuild.config.ts" {8-24}
120+
```ts title="rsbuild.config.ts"
120121
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
121122
import { defineConfig } from '@rsbuild/core';
122123
import { pluginReact } from '@rsbuild/plugin-react';
123124

124125
export default defineConfig({
125126
plugins: [
126127
pluginReact(),
127-
pluginModuleFederation({
128-
name: 'rsbuild_host',
129-
remotes: {
130-
rslib: 'rslib@http://localhost:3001/mf/mf-manifest.json',
131-
},
132-
shared: {
133-
react: {
134-
singleton: true,
135-
},
136-
'react-dom': {
137-
singleton: true,
138-
},
139-
},
140-
// 开启这个当 Rslib 产物为 'production' 模式, 但是宿主应用是 'development' 模式。
141-
// 参考链接: https://lib.rsbuild.dev/guide/advanced/module-federation#faqs
142-
shareStrategy: 'loaded-first',
143-
}),
128+
pluginModuleFederation({ // [!code highlight]
129+
name: 'rsbuild_host', // [!code highlight]
130+
remotes: { // [!code highlight]
131+
rslib: 'rslib@http://localhost:3001/mf/mf-manifest.json', // [!code highlight]
132+
}, // [!code highlight]
133+
shared: { // [!code highlight]
134+
react: { // [!code highlight]
135+
singleton: true, // [!code highlight]
136+
}, // [!code highlight]
137+
'react-dom': { // [!code highlight]
138+
singleton: true, // [!code highlight]
139+
}, // [!code highlight]
140+
}, // [!code highlight]
141+
// 开启这个当 Rslib 产物为 'production' 模式, 但是宿主应用是 'development' 模式。 // [!code highlight]
142+
// 参考链接: https://lib.rsbuild.dev/guide/advanced/module-federation#faqs // [!code highlight]
143+
shareStrategy: 'loaded-first', // [!code highlight]
144+
}), // [!code highlight]
144145
],
145146
});
146147
```
@@ -181,7 +182,7 @@ Rslib 支持使用 Storybook 开发 Rslib 模块联邦项目。
181182

182183
2. 然后创建 Storybook 配置文件 `.storybook/main.ts`,指定 stories 和 addons,并设置 framework 和相应的 framework 集成。
183184

184-
```ts title=".storybook/main.ts" {18-38}
185+
```ts title=".storybook/main.ts"
185186
import { dirname, join } from 'node:path';
186187
import type { StorybookConfig } from 'storybook-react-rsbuild';
187188

@@ -199,7 +200,7 @@ const config: StorybookConfig = {
199200
options: {},
200201
},
201202
addons: [
202-
{
203+
{ // [!code highlight:20]
203204
name: getAbsolutePath('storybook-addon-rslib'),
204205
options: {
205206
rslib: {
@@ -230,10 +231,10 @@ export default config;
230231

231232
从远程模块引入组件
232233

233-
```ts title="stories/index.stories.tsx" {2-3}
234+
```ts title="stories/index.stories.tsx"
234235
import React from 'react';
235-
// 在这里加载远程模块,Storybook 相当于宿主应用.
236-
import { Counter } from 'rslib-module';
236+
// 在这里加载远程模块,Storybook 相当于宿主应用. // [!code highlight]
237+
import { Counter } from 'rslib-module'; // [!code highlight]
237238

238239
const Component = () => <Counter />;
239240

website/docs/zh/guide/basic/output-format.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@ StackOverflow 上的详细回答:[什么是通用模块定义 (UMD)?](https:
9292
- `output.externals.react: 'React'`: 指定外部依赖 `react` 可以通过 `window.React` 访问。
9393
- `runtime: 'classic'`: 使用 React 的 classic 运行时,以支持使用 React 版本低于 18 的应用程序。
9494

95-
```ts title="rslib.config.ts" {7-12,22}
95+
```ts title="rslib.config.ts"
9696
import { pluginReact } from '@rsbuild/plugin-react';
9797
import { defineConfig } from '@rslib/core';
9898

9999
export default defineConfig({
100100
lib: [
101101
{
102-
format: 'umd',
103-
umdName: 'RslibUmdExample',
102+
format: 'umd', // [!code highlight]
103+
umdName: 'RslibUmdExample', // [!code highlight]
104104
output: {
105105
externals: {
106-
react: 'React',
106+
react: 'React', // [!code highlight]
107107
},
108108
distPath: {
109109
root: './dist/umd',
@@ -117,7 +117,7 @@ export default defineConfig({
117117
plugins: [
118118
pluginReact({
119119
swcReactOptions: {
120-
runtime: 'classic',
120+
runtime: 'classic', // [!code highlight]
121121
},
122122
}),
123123
],

website/docs/zh/guide/solution/react.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ import { PackageManagerTabs } from '@theme';
2727

2828
例如,在 `rslib.config.ts` 中注册:
2929

30-
```ts title="rslib.config.ts" {2,8-11}
30+
```ts title="rslib.config.ts"
3131
import { defineConfig } from '@rslib/core';
32-
import { pluginReact } from '@rsbuild/plugin-react';
32+
import { pluginReact } from '@rsbuild/plugin-react'; // [!code highlight]
3333

3434
export default defineConfig({
3535
lib: [
3636
// ...
3737
],
3838
output: {
39-
target: 'web',
39+
target: 'web', // [!code highlight]
4040
},
41-
plugins: [pluginReact(/** options here */)],
41+
plugins: [pluginReact(/** options here */)], // [!code highlight]
4242
});
4343
```
4444

@@ -53,7 +53,7 @@ React 引入了一个 [新的 JSX transform](https://legacy.reactjs.org/blog/202
5353

5454
要更改 JSX transform,可以传递 [swcReactOptions](https://rsbuild.dev/zh/plugins/list/plugin-react#swcreactoptionsruntime) 给 React plugin. 比如要使用 classic runtime 时:
5555

56-
```ts title="rslib.config.ts" {13-15}
56+
```ts title="rslib.config.ts"
5757
import { pluginReact } from '@rsbuild/plugin-react';
5858
import { defineConfig } from '@rslib/core';
5959

@@ -66,9 +66,9 @@ export default defineConfig({
6666
},
6767
plugins: [
6868
pluginReact({
69-
swcReactOptions: {
70-
runtime: 'classic',
71-
},
69+
swcReactOptions: { // [!code highlight]
70+
runtime: 'classic', // [!code highlight]
71+
}, // [!code highlight]
7272
}),
7373
],
7474
});
@@ -83,7 +83,7 @@ export default defineConfig({
8383

8484
例如,当使用 [Emotion](https://emotion.sh/),你可以设置 `importSource``'@emotion/react'`:
8585

86-
```ts title="rslib.config.ts" {13-15}
86+
```ts title="rslib.config.ts"
8787
import { pluginReact } from '@rsbuild/plugin-react';
8888
import { defineConfig } from '@rslib/core';
8989

@@ -96,9 +96,9 @@ export default defineConfig({
9696
},
9797
plugins: [
9898
pluginReact({
99-
swcReactOptions: {
100-
importSource: '@emotion/react',
101-
},
99+
swcReactOptions: { // [!code highlight]
100+
importSource: '@emotion/react', // [!code highlight]
101+
}, // [!code highlight]
102102
}),
103103
],
104104
});

0 commit comments

Comments
 (0)