Skip to content

Commit da2225f

Browse files
committed
chore: update
1 parent 81d7beb commit da2225f

File tree

12 files changed

+122
-100
lines changed

12 files changed

+122
-100
lines changed

website/docs/en/config/lib/dts.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export default {
7878
lib: [
7979
{
8080
format: 'esm',
81+
// [!code highlight:3]
8182
dts: {
82-
// [!code highlight]
83-
bundle: true, // [!code highlight]
84-
}, // [!code highlight]
83+
bundle: true,
84+
},
8585
},
8686
],
8787
};
@@ -112,10 +112,10 @@ export default {
112112
lib: [
113113
{
114114
format: 'esm',
115+
// [!code highlight:3]
115116
dts: {
116-
// [!code highlight]
117-
distPath: './dist-types', // [!code highlight]
118-
}, // [!code highlight]
117+
distPath: './dist-types',
118+
},
119119
},
120120
],
121121
};
@@ -150,10 +150,10 @@ export default {
150150
lib: [
151151
{
152152
format: 'esm',
153+
// [!code highlight:3]
153154
dts: {
154-
// [!code highlight]
155-
abortOnError: false, // [!code highlight]
156-
}, // [!code highlight]
155+
abortOnError: false,
156+
},
157157
},
158158
],
159159
};

website/docs/en/config/lib/external-helpers.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ export default {
9494
Below is the output JavaScript file, the highlighted code is importing helper functions:
9595

9696
```js title="index.js"
97-
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__ from '@swc/helpers/_/_class_call_check'; // [!code highlight]
98-
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__ from '@swc/helpers/_/_create_class'; // [!code highlight]
97+
// [!code highlight:2]
98+
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__ from '@swc/helpers/_/_class_call_check';
99+
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__ from '@swc/helpers/_/_create_class';
99100
var src_FOO = /*#__PURE__*/ (function () {
100101
'use strict';
101102
function FOO() {

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { defineConfig } from '@rslib/core';
3838
export default defineConfig({
3939
lib: [
4040
// ... other format
41-
// [!code highlight:35]
41+
// [!code highlight:37]
4242
{
4343
format: 'mf',
4444
output: {
@@ -126,23 +126,24 @@ import { pluginReact } from '@rsbuild/plugin-react';
126126
export default defineConfig({
127127
plugins: [
128128
pluginReact(),
129-
pluginModuleFederation({ // [!code highlight]
130-
name: 'rsbuild_host', // [!code highlight]
131-
remotes: { // [!code highlight]
132-
rslib: 'rslib@http://localhost:3001/mf/mf-manifest.json', // [!code highlight]
133-
}, // [!code highlight]
134-
shared: { // [!code highlight]
135-
react: { // [!code highlight]
136-
singleton: true, // [!code highlight]
137-
}, // [!code highlight]
138-
'react-dom': { // [!code highlight]
139-
singleton: true, // [!code highlight]
140-
}, // [!code highlight]
141-
}, // [!code highlight]
142-
// Enable this when the output of Rslib is build under 'production' mode, while the host app is 'development'. // [!code highlight]
143-
// Reference: https://lib.rsbuild.dev/guide/advanced/module-federation#faqs // [!code highlight]
144-
shareStrategy: 'loaded-first', // [!code highlight]
145-
}), // [!code highlight]
129+
// [!code highlight:17]
130+
pluginModuleFederation({
131+
name: 'rsbuild_host',
132+
remotes: {
133+
rslib: 'rslib@http://localhost:3001/mf/mf-manifest.json',
134+
},
135+
shared: {
136+
react: {
137+
singleton: true,
138+
},
139+
'react-dom': {
140+
singleton: true,
141+
},
142+
},
143+
// Enable this when the output of Rslib is build under 'production' mode, while the host app is 'development'.
144+
// Reference: https://lib.rsbuild.dev/guide/advanced/module-federation#faqs
145+
shareStrategy: 'loaded-first',
146+
}),
146147
],
147148
});
148149
```
@@ -200,7 +201,8 @@ First, set up Storybook with the Rslib project. You can refer to the [Storybook
200201
options: {},
201202
},
202203
addons: [
203-
{ // [!code highlight:20]
204+
// [!code highlight:21]
205+
{
204206
name: getAbsolutePath('storybook-addon-rslib'),
205207
options: {
206208
rslib: {
@@ -233,8 +235,9 @@ Import components from remote module.
233235

234236
```ts title="stories/index.stories.tsx"
235237
import React from 'react';
236-
// Load your remote module here, Storybook will act as the host app. // [!code highlight]
237-
import { Counter } from 'rslib-module'; // [!code highlight]
238+
// [!code highlight:2]
239+
// Load your remote module here, Storybook will act as the host app.
240+
import { Counter } from 'rslib-module';
238241

239242
const Component = () => <Counter />;
240243

website/docs/en/guide/advanced/output-compatibility.mdx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,21 @@ export default defineConfig({
4646
},
4747
],
4848
plugins: [
49-
pluginBabel({ // [!code highlight]
50-
babelLoaderOptions: { // [!code highlight]
51-
plugins: [ // [!code highlight]
52-
[ // [!code highlight]
53-
require('babel-plugin-polyfill-corejs3'), // [!code highlight]
54-
{ // [!code highlight]
55-
method: 'usage-pure', // [!code highlight]
56-
targets: { ie: '10' }, // [!code highlight]
57-
version: '3.29', // [!code highlight]
58-
}, // [!code highlight]
59-
], // [!code highlight]
60-
], // [!code highlight]
61-
}, // [!code highlight]
62-
}), // [!code highlight]
49+
// [!code highlight:14]
50+
pluginBabel({
51+
babelLoaderOptions: {
52+
plugins: [
53+
[
54+
require('babel-plugin-polyfill-corejs3'),
55+
{
56+
method: 'usage-pure',
57+
targets: { ie: '10' },
58+
version: '3.29',
59+
},
60+
],
61+
],
62+
},
63+
}),
6364
],
6465
});
6566
```

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ import { defineConfig } from '@rslib/core';
104104
export default defineConfig({
105105
lib: [
106106
{
107-
format: 'umd', // [!code highlight]
108-
umdName: 'RslibUmdExample', // [!code highlight]
107+
// [!code highlight:6]
108+
format: 'umd',
109+
umdName: 'RslibUmdExample',
109110
output: {
110111
externals: {
111-
react: 'React', // [!code highlight]
112+
react: 'React',
112113
},
113114
distPath: {
114115
root: './dist/umd',

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ export default defineConfig({
3535
lib: [
3636
// ...
3737
],
38+
// [!code highlight:4]
3839
output: {
39-
target: 'web', // [!code highlight]
40+
target: 'web',
4041
},
41-
plugins: [pluginReact(/** options here */)], // [!code highlight]
42+
plugins: [pluginReact(/** options here */)],
4243
});
4344
```
4445

@@ -66,9 +67,10 @@ export default defineConfig({
6667
},
6768
plugins: [
6869
pluginReact({
69-
swcReactOptions: { // [!code highlight]
70-
runtime: 'classic', // [!code highlight]
71-
}, // [!code highlight]
70+
// [!code highlight:3]
71+
swcReactOptions: {
72+
runtime: 'classic',
73+
},
7274
}),
7375
],
7476
});
@@ -96,9 +98,10 @@ export default defineConfig({
9698
},
9799
plugins: [
98100
pluginReact({
99-
swcReactOptions: { // [!code highlight]
100-
importSource: '@emotion/react', // [!code highlight]
101-
}, // [!code highlight]
101+
// [!code highlight:3]
102+
swcReactOptions: {
103+
importSource: '@emotion/react',
104+
},
102105
}),
103106
],
104107
});

website/docs/zh/config/lib/dts.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ export default {
7878
lib: [
7979
{
8080
format: 'esm',
81+
// [!code highlight:3]
8182
dts: {
82-
bundle: true, // [!code highlight]
83+
bundle: true,
8384
},
8485
},
8586
],
@@ -111,8 +112,9 @@ export default {
111112
lib: [
112113
{
113114
format: 'esm',
115+
// [!code highlight:3]
114116
dts: {
115-
distPath: './dist-types', // [!code highlight]
117+
distPath: './dist-types',
116118
},
117119
},
118120
],
@@ -148,8 +150,9 @@ export default {
148150
lib: [
149151
{
150152
format: 'esm',
153+
// [!code highlight:3]
151154
dts: {
152-
abortOnError: false, // [!code highlight]
155+
abortOnError: false,
153156
},
154157
},
155158
],

website/docs/zh/config/lib/external-helpers.mdx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,21 @@ export default class FOO {
2929

3030
`externalHelpers` 禁用时,输出的 JavaScript 将内联辅助函数。
3131

32-
```ts title="rslib.config.ts" {5}
32+
```ts title="rslib.config.ts"
3333
export default {
3434
lib: [
3535
{
3636
syntax: 'es5',
37-
externalHelpers: false,
37+
externalHelpers: false, // [!code highlight]
3838
},
3939
],
4040
};
4141
```
4242

4343
以下是输出的 JavaScript 文件,高亮部分是内联的辅助函数:
4444

45-
```js title="index.js" {1-18}
45+
```js title="index.js"
46+
// [!code highlight:18]
4647
function _class_call_check(instance, Constructor) {
4748
if (!(instance instanceof Constructor))
4849
throw new TypeError('Cannot call a class as a function');
@@ -79,20 +80,21 @@ export { src_FOO as default };
7980

8081
当启用 `externalHelpers` 时,输出的 JavaScript 将从外部模块 `@swc/helpers` 导入辅助函数。
8182

82-
```ts title="rslib.config.ts" {5}
83+
```ts title="rslib.config.ts"
8384
export default {
8485
lib: [
8586
{
8687
syntax: 'es5',
87-
externalHelpers: true,
88+
externalHelpers: true, // [!code highlight]
8889
},
8990
],
9091
};
9192
```
9293

9394
以下是输出的 JavaScript 文件,高亮部分是导入的辅助函数:
9495

95-
```js title="index.js" {1-2}
96+
```js title="index.js"
97+
// [!code highlight:2]
9698
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_class_call_check__ from '@swc/helpers/_/_class_call_check';
9799
import * as __WEBPACK_EXTERNAL_MODULE__swc_helpers_create_class__ from '@swc/helpers/_/_create_class';
98100
var src_FOO = /*#__PURE__*/ (function () {

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

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { defineConfig } from '@rslib/core';
3838
export default defineConfig({
3939
lib: [
4040
// ... 其他 format
41-
// [!code highlight:35]
41+
// [!code highlight:37]
4242
{
4343
format: 'mf',
4444
output: {
@@ -125,23 +125,24 @@ import { pluginReact } from '@rsbuild/plugin-react';
125125
export default defineConfig({
126126
plugins: [
127127
pluginReact(),
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]
128+
// [!code highlight:17]
129+
pluginModuleFederation({
130+
name: 'rsbuild_host',
131+
remotes: {
132+
rslib: 'rslib@http://localhost:3001/mf/mf-manifest.json',
133+
},
134+
shared: {
135+
react: {
136+
singleton: true,
137+
},
138+
'react-dom': {
139+
singleton: true,
140+
},
141+
},
142+
// 开启这个当 Rslib 产物为 'production' 模式, 但是宿主应用是 'development' 模式。
143+
// 参考链接: https://lib.rsbuild.dev/guide/advanced/module-federation#faqs
144+
shareStrategy: 'loaded-first',
145+
}),
145146
],
146147
});
147148
```
@@ -200,7 +201,8 @@ const config: StorybookConfig = {
200201
options: {},
201202
},
202203
addons: [
203-
{ // [!code highlight:20]
204+
// [!code highlight:21]
205+
{
204206
name: getAbsolutePath('storybook-addon-rslib'),
205207
options: {
206208
rslib: {
@@ -233,8 +235,9 @@ export default config;
233235

234236
```ts title="stories/index.stories.tsx"
235237
import React from 'react';
236-
// 在这里加载远程模块,Storybook 相当于宿主应用. // [!code highlight]
237-
import { Counter } from 'rslib-module'; // [!code highlight]
238+
// [!code highlight:2]
239+
// 在这里加载远程模块,Storybook 相当于宿主应用.
240+
import { Counter } from 'rslib-module';
238241

239242
const Component = () => <Counter />;
240243

website/docs/zh/guide/advanced/output-compatibility.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ polyfill 依赖于 Babel 注入 polyfill 代码,因此你需要安装 [Rsbuild
3535

3636
配置 Babel 插件,设置 [targets](https://babeljs.io/docs/options#targets) 字段以指定目标浏览器版本。
3737

38-
```ts title="rslib.config.ts" {1,11-24}
39-
import { pluginBabel } from '@rsbuild/plugin-babel';
38+
```ts title="rslib.config.ts"
39+
import { pluginBabel } from '@rsbuild/plugin-babel'; // [!code highlight]
4040
import { defineConfig } from '@rslib/core';
4141

4242
export default defineConfig({
@@ -46,6 +46,7 @@ export default defineConfig({
4646
},
4747
],
4848
plugins: [
49+
// [!code highlight:14]
4950
pluginBabel({
5051
babelLoaderOptions: {
5152
plugins: [

0 commit comments

Comments
 (0)