Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
SoonIter committed Dec 12, 2024
1 parent b244a96 commit 972876d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 53 deletions.
2 changes: 1 addition & 1 deletion website/docs/zh/guide/advanced/dts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ import { PackageManagerTabs } from '@theme';

你可以参考 [lib.dts](/config/lib/dts) 获取更多有关 DTS 配置的详细信息。

:::
:::
90 changes: 45 additions & 45 deletions website/docs/zh/guide/advanced/module-federation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default defineConfig({

Rslib 支持使用 Storybook 开发 Module Federation Rslib 项目。

#### 1. 启动库的 MF `dev`
#### 1. 启动库的 MF `dev`

添加 `dev` 命令在 `package.json` 文件:

Expand Down Expand Up @@ -179,52 +179,52 @@ Rslib 支持使用 Storybook 开发 Module Federation Rslib 项目。

<PackageManagerTabs command="add storybook-addon-rslib @module-federation/storybook-addon -D" />

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

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

function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')));
}

const config: StorybookConfig = {
stories: [
'../stories/**/*.mdx',
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
framework: {
name: getAbsolutePath('storybook-react-rsbuild'),
options: {},
},
addons: [
{
name: getAbsolutePath('storybook-addon-rslib'),
options: {
rslib: {
include: ['**/stories/**'],
},
},
},
{
name: '@module-federation/storybook-addon/preset',
options: {
// 在添加 rslib module manifest 给 storybook dev
// 我们在上面已经设置了 dev.assetPrefix 和 server.port 到 3001 在 rslib.config.ts
remotes: {
'rslib-module':
//还可以在这里添加 storybook 的 shared
// shared: {}
'rslib-module@http://localhost:3001/mf/mf-manifest.json',
},
},
},
],
};

export default config;
```
import { dirname, join } from 'node:path';
import type { StorybookConfig } from 'storybook-react-rsbuild';

function getAbsolutePath(value: string): any {
return dirname(require.resolve(join(value, 'package.json')));
}

const config: StorybookConfig = {
stories: [
'../stories/**/*.mdx',
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
],
framework: {
name: getAbsolutePath('storybook-react-rsbuild'),
options: {},
},
addons: [
{
name: getAbsolutePath('storybook-addon-rslib'),
options: {
rslib: {
include: ['**/stories/**'],
},
},
},
{
name: '@module-federation/storybook-addon/preset',
options: {
// 在添加 rslib module manifest 给 storybook dev
// 我们在上面已经设置了 dev.assetPrefix 和 server.port 到 3001 在 rslib.config.ts
remotes: {
'rslib-module':
//还可以在这里添加 storybook 的 shared
// shared: {}
'rslib-module@http://localhost:3001/mf/mf-manifest.json',
},
},
},
],
};

export default config;
```

#### 3. 用远程模块 编写 stories

Expand Down
4 changes: 2 additions & 2 deletions website/docs/zh/guide/solution/nodejs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default defineConfig({
});
```

## Node.js 中的 target
## Node.js 中的 target

Rslib 默认将 [target](/config/rsbuild/output#outputtarget) 设置为 `"node"`,这与 Rsbuild 的target 默认值不同。

Expand All @@ -68,4 +68,4 @@ Rslib 默认将 [target](/config/rsbuild/output#outputtarget) 设置为 `"node"`

{/* TODO: Rspack doesn't support createRequire now */}
{/* ### createRequire */}
{/* Requiring module with [createRequire](https://nodejs.org/api/module.html#modulecreaterequirefilename) will also works in ESM format. */}
{/* Requiring module with [createRequire](https://nodejs.org/api/module.html#modulecreaterequirefilename) will also works in ESM format. */}
2 changes: 1 addition & 1 deletion website/docs/zh/guide/solution/react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ export default defineConfig({
## 进一步了解

- [Rsbuild React Plugin](https://rsbuild.dev/plugins/list/plugin-react#swcreactoptionsruntime)
- [SWC Compilation - jsc.transform.react](https://swc.rs/docs/configuration/compilation#jsctransformreact)
- [SWC Compilation - jsc.transform.react](https://swc.rs/docs/configuration/compilation#jsctransformreact)
6 changes: 3 additions & 3 deletions website/docs/zh/guide/start/glossary.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CJS 代表 [CommonJS](https://nodejs.org/api/modules.html#modules-commonjs-modul

## UMD

<UMD/>
<UMD />

## 无捆绑

Expand All @@ -27,8 +27,8 @@ DTS代表[TypeScript声明文件](https://www.typescriptlang.org/docs/handbook/d

## 模块联盟

<MF/>
<MF />

## 更多

请参阅 [Rsbuild-术语表](https://rsbuild.dev/guide/start/glossary)[Rspack-术语表](https://rspack.dev/misc/glossary) 中的更多术语。
请参阅 [Rsbuild-术语表](https://rsbuild.dev/guide/start/glossary)[Rspack-术语表](https://rspack.dev/misc/glossary) 中的更多术语。
1 change: 0 additions & 1 deletion website/docs/zh/guide/start/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,3 @@ Options:

- [从 tsup 迁移](/guide/migration/tsup)
- [从 Modern.js Module 迁移](/guide/migration/modernjs-module)

0 comments on commit 972876d

Please sign in to comment.