@modern-js/main-doc 2.67.6 → 2.67.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/docs/en/apis/app/commands.mdx +3 -3
  2. package/docs/en/apis/app/hooks/src/routes.mdx +0 -70
  3. package/docs/en/community/blog/v2-release-note.mdx +2 -2
  4. package/docs/en/community/contributing-guide.mdx +1 -1
  5. package/docs/en/components/builder.mdx +1 -1
  6. package/docs/en/components/bundler.mdx +1 -1
  7. package/docs/en/components/rsbuild.mdx +1 -1
  8. package/docs/en/components/rspack.mdx +1 -1
  9. package/docs/en/components/rspackPrecautions.mdx +2 -2
  10. package/docs/en/configure/app/builder-plugins.mdx +1 -1
  11. package/docs/en/configure/app/output/assets-retry.mdx +1 -1
  12. package/docs/en/configure/app/output/copy.mdx +1 -1
  13. package/docs/en/configure/app/performance/build-cache.mdx +1 -1
  14. package/docs/en/configure/app/performance/transform-lodash.mdx +4 -1
  15. package/docs/en/configure/app/security/sri.mdx +1 -1
  16. package/docs/en/configure/app/source/exclude.mdx +2 -2
  17. package/docs/en/configure/app/source/include.mdx +1 -1
  18. package/docs/en/configure/app/source/module-scopes.mdx +4 -1
  19. package/docs/en/configure/app/source/transform-import.mdx +2 -2
  20. package/docs/en/configure/app/tools/babel.mdx +5 -5
  21. package/docs/en/configure/app/tools/bundler-chain.mdx +2 -2
  22. package/docs/en/configure/app/tools/css-extract.mdx +1 -1
  23. package/docs/en/configure/app/tools/dev-server.mdx +1 -1
  24. package/docs/en/configure/app/tools/lightningcss-loader.mdx +1 -1
  25. package/docs/en/configure/app/tools/rspack.mdx +1 -1
  26. package/docs/en/configure/app/tools/swc.mdx +3 -3
  27. package/docs/en/configure/app/tools/terser.mdx +4 -2
  28. package/docs/en/configure/app/tools/ts-loader.mdx +4 -1
  29. package/docs/en/configure/app/tools/webpack-chain.mdx +22 -19
  30. package/docs/en/configure/app/tools/webpack.mdx +4 -1
  31. package/docs/en/guides/advanced-features/build-performance.mdx +1 -1
  32. package/docs/en/guides/advanced-features/compatibility.mdx +1 -1
  33. package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +3 -3
  34. package/docs/en/guides/advanced-features/rspack-start.mdx +2 -2
  35. package/docs/en/guides/advanced-features/web-server.mdx +16 -4
  36. package/docs/en/guides/basic-features/css/css.mdx +4 -4
  37. package/docs/en/guides/basic-features/data/data-cache.mdx +1 -1
  38. package/docs/en/guides/basic-features/debug/rsdoctor.mdx +1 -1
  39. package/docs/en/guides/basic-features/render/ssr.mdx +1 -1
  40. package/docs/en/guides/basic-features/render/streaming-ssr.mdx +2 -2
  41. package/docs/en/guides/basic-features/routes.mdx +75 -3
  42. package/docs/en/guides/basic-features/static-assets/wasm-assets.mdx +1 -1
  43. package/docs/en/guides/basic-features/static-assets.mdx +1 -1
  44. package/docs/en/guides/concept/builder.mdx +3 -3
  45. package/docs/en/guides/concept/entries.mdx +1 -1
  46. package/docs/en/guides/get-started/tech-stack.mdx +3 -3
  47. package/docs/en/guides/topic-detail/module-federation/deploy.mdx +83 -7
  48. package/docs/en/guides/topic-detail/module-federation/usage.mdx +2 -4
  49. package/docs/en/guides/troubleshooting/builder.mdx +4 -5
  50. package/docs/en/plugin/cli-plugins/api.mdx +141 -135
  51. package/docs/en/plugin/introduction.mdx +27 -24
  52. package/docs/en/tutorials/examples/csr-auth.mdx +15 -198
  53. package/docs/zh/apis/app/commands.mdx +3 -3
  54. package/docs/zh/community/blog/v2-release-note.mdx +2 -2
  55. package/docs/zh/community/contributing-guide.mdx +1 -1
  56. package/docs/zh/components/builder.mdx +1 -1
  57. package/docs/zh/components/bundler.mdx +1 -2
  58. package/docs/zh/components/rsbuild.mdx +1 -1
  59. package/docs/zh/components/rspack.mdx +1 -1
  60. package/docs/zh/components/rspackPrecautions.mdx +2 -2
  61. package/docs/zh/configure/app/builder-plugins.mdx +1 -1
  62. package/docs/zh/configure/app/output/assets-retry.mdx +1 -1
  63. package/docs/zh/configure/app/output/copy.mdx +1 -1
  64. package/docs/zh/configure/app/performance/build-cache.mdx +1 -1
  65. package/docs/zh/configure/app/performance/transform-lodash.mdx +4 -1
  66. package/docs/zh/configure/app/security/sri.mdx +1 -1
  67. package/docs/zh/configure/app/source/exclude.mdx +2 -2
  68. package/docs/zh/configure/app/source/include.mdx +1 -1
  69. package/docs/zh/configure/app/source/module-scopes.mdx +4 -1
  70. package/docs/zh/configure/app/source/transform-import.mdx +2 -2
  71. package/docs/zh/configure/app/tools/babel.mdx +5 -6
  72. package/docs/zh/configure/app/tools/bundler-chain.mdx +2 -2
  73. package/docs/zh/configure/app/tools/css-extract.mdx +1 -1
  74. package/docs/zh/configure/app/tools/dev-server.mdx +1 -1
  75. package/docs/zh/configure/app/tools/lightningcss-loader.mdx +1 -1
  76. package/docs/zh/configure/app/tools/rspack.mdx +1 -1
  77. package/docs/zh/configure/app/tools/swc.mdx +3 -3
  78. package/docs/zh/configure/app/tools/terser.mdx +4 -2
  79. package/docs/zh/configure/app/tools/ts-loader.mdx +4 -1
  80. package/docs/zh/configure/app/tools/webpack-chain.mdx +23 -20
  81. package/docs/zh/configure/app/tools/webpack.mdx +4 -1
  82. package/docs/zh/guides/advanced-features/compatibility.mdx +1 -1
  83. package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +2 -2
  84. package/docs/zh/guides/advanced-features/rspack-start.mdx +2 -2
  85. package/docs/zh/guides/advanced-features/web-server.mdx +17 -4
  86. package/docs/zh/guides/basic-features/css/css.mdx +4 -4
  87. package/docs/zh/guides/basic-features/data/data-cache.mdx +1 -1
  88. package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +1 -1
  89. package/docs/zh/guides/basic-features/render/ssr.mdx +1 -1
  90. package/docs/zh/guides/basic-features/render/streaming-ssr.mdx +1 -1
  91. package/docs/zh/guides/basic-features/static-assets/wasm-assets.mdx +1 -1
  92. package/docs/zh/guides/basic-features/static-assets.mdx +2 -2
  93. package/docs/zh/guides/concept/builder.mdx +3 -3
  94. package/docs/zh/guides/concept/entries.mdx +1 -1
  95. package/docs/zh/guides/get-started/tech-stack.mdx +3 -3
  96. package/docs/zh/guides/topic-detail/module-federation/deploy.mdx +83 -7
  97. package/docs/zh/guides/topic-detail/module-federation/usage.mdx +2 -4
  98. package/docs/zh/guides/troubleshooting/builder.mdx +4 -5
  99. package/docs/zh/plugin/cli-plugins/api.mdx +123 -121
  100. package/docs/zh/plugin/introduction.mdx +18 -15
  101. package/docs/zh/tutorials/examples/csr-auth.mdx +15 -198
  102. package/package.json +6 -6
  103. package/rspress.config.ts +12 -1
  104. package/src/components/RsbuildLink/index.tsx +1 -1
  105. package/src/components/Sandpack/index.tsx +1 -11
  106. package/src/components/ShowcaseList/useShowcases.ts +1 -1
  107. package/src/sandbox/csr-auth/src/routes/Auth-tsx.txt +74 -0
  108. package/src/sandbox/csr-auth/src/routes/fakeAuth-ts.txt +16 -0
  109. package/src/sandbox/csr-auth/src/routes/layout-tsx.txt +21 -0
  110. package/src/sandbox/csr-auth/src/routes/login/page-tsx.txt +40 -0
  111. package/src/sandbox/csr-auth/src/routes/page-tsx.txt +17 -0
  112. package/src/sandbox/csr-auth/src/routes/protected/page-tsx.txt +11 -0
@@ -12,203 +12,20 @@ In a web application, if there are multiple routes, we may need to authorize acc
12
12
  - Access to the `/protected` route requires authorization. If there is no authorization, it will automatically redirect to the `/login` route. After successful login, it returns to `/protected`.
13
13
 
14
14
  import Sandpack from '@site/src/components/Sandpack';
15
+ import srcRoutesPageText from '../../../../src/sandbox/csr-auth/src/routes/page-tsx.txt';
16
+ import srcRoutesLayoutText from '../../../../src/sandbox/csr-auth/src/routes/layout-tsx.txt';
17
+ import srcRoutesAuthText from '../../../../src/sandbox/csr-auth/src/routes/Auth-tsx.txt';
18
+ import srcRoutesFakeAuthText from '../../../../src/sandbox/csr-auth/src/routes/fakeAuth-ts.txt';
19
+ import srcRoutesProtectedPageText from '../../../../src/sandbox/csr-auth/src/routes/protected/page-tsx.txt';
20
+ import srcRoutesLoginPageText from '../../../../src/sandbox/csr-auth/src/routes/login/page-tsx.txt';
21
+
22
+ <Sandpack template="web-app" files={{
23
+ '/src/routes/page.tsx': srcRoutesPageText,
24
+ '/src/routes/layout.tsx': srcRoutesLayoutText,
25
+ '/src/routes/Auth.tsx': srcRoutesAuthText,
26
+ '/src/routes/fakeAuth.ts': srcRoutesFakeAuthText,
27
+ '/src/routes/protected/page.tsx': srcRoutesProtectedPageText,
28
+ '/src/routes/login/page.tsx': srcRoutesLoginPageText,
29
+ }}>
15
30
 
16
- <Sandpack template="web-app">
17
- ```tsx title="src/routes/page.tsx"
18
- import { Helmet } from '@modern-js/runtime/head';
19
- import './index.css';
20
-
21
- const PublicPage = (): JSX.Element => (
22
- <div className="container-box">
23
- <Helmet>
24
- <link
25
- rel="icon"
26
- type="image/x-icon"
27
- href="https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/favicon.ico"
28
- />
29
- </Helmet>
30
- <h3>Public</h3>
31
- </div>
32
- );
33
-
34
- export default PublicPage;
35
-
36
- ```
37
- ```tsx title="src/routes/layout.tsx"
38
- import { Link, Outlet } from '@modern-js/runtime/router';
39
- import { AuthProvider, AuthStatus } from './Auth';
40
-
41
- export default function Layout() {
42
- return (
43
- <AuthProvider>
44
- <AuthStatus />
45
-
46
- <ul>
47
- <li>
48
- <Link to="/">Public Page</Link>
49
- </li>
50
- <li>
51
- <Link to="/protected">Protected Page</Link>
52
- </li>
53
- </ul>
54
-
55
- <Outlet />
56
- </AuthProvider>
57
- );
58
- }
59
-
60
- ```
61
- ```ts title="src/routes/fakeAuth.ts"
62
- /**
63
- * This represents some generic auth provider API, like Firebase.
64
- */
65
- const fakeAuthProvider = {
66
- isAuthenticated: false,
67
- signin(callback: VoidFunction) {
68
- fakeAuthProvider.isAuthenticated = true;
69
- setTimeout(callback, 100); // fake async
70
- },
71
- signout(callback: VoidFunction) {
72
- fakeAuthProvider.isAuthenticated = false;
73
- setTimeout(callback, 100);
74
- },
75
- };
76
-
77
- export { fakeAuthProvider };
78
-
79
- ```
80
- ```ts title="src/routes/Auth.tsx"
81
- import React from 'react';
82
- import { useNavigate, Navigate, useLocation } from '@modern-js/runtime/router';
83
- import { fakeAuthProvider } from './fakeAuth';
84
-
85
- interface AuthContextType {
86
- user: any;
87
- signin: (user: string, callback: VoidFunction) => void;
88
- signout: (callback: VoidFunction) => void;
89
- }
90
-
91
- const AuthContext = React.createContext<AuthContextType>(null!);
92
-
93
- export function AuthProvider({ children }: { children: React.ReactNode }) {
94
- const [user, setUser] = React.useState<any>(null);
95
-
96
- const signin = (newUser: string, callback: VoidFunction) =>
97
- fakeAuthProvider.signin(() => {
98
- setUser(newUser);
99
- callback();
100
- });
101
-
102
- const signout = (callback: VoidFunction) =>
103
- fakeAuthProvider.signout(() => {
104
- setUser(null);
105
- callback();
106
- });
107
-
108
- const value = { user, signin, signout };
109
-
110
- return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
111
- }
112
-
113
- export function useAuth() {
114
- return React.useContext(AuthContext);
115
- }
116
-
117
- export function AuthStatus() {
118
- const auth = useAuth();
119
- console.log('auth', auth);
120
- const navigate = useNavigate();
121
-
122
- if (!auth.user) {
123
- return <p>You are not logged in.</p>;
124
- }
125
-
126
- return (
127
- <p>
128
- Welcome {auth.user}!{' '}
129
- <button
130
- type="button"
131
- onClick={() => {
132
- auth.signout(() => navigate('/'));
133
- }}
134
- >
135
- Sign out
136
- </button>
137
- </p>
138
- );
139
- }
140
-
141
- export function RequireAuth({ children }: { children: JSX.Element }) {
142
- const auth = useAuth();
143
- const location = useLocation();
144
-
145
- if (!auth.user) {
146
- // Redirect them to the /login page, but save the current location they were
147
- // trying to go to when they were redirected. This allows us to send them
148
- // along to that page after they login, which is a nicer user experience
149
- // than dropping them off on the home page.
150
- return <Navigate to="/login" state={{ from: location }} replace />;
151
- }
152
-
153
- return children;
154
- }
155
-
156
- ```
157
- ```ts title="src/routes/protected/page.tsx"
158
- import { RequireAuth } from '../Auth';
159
-
160
- export default function ProtectedPage() {
161
- return (
162
- <div className="container-box">
163
- <RequireAuth>
164
- <h3>Protected</h3>
165
- </RequireAuth>
166
- </div>
167
- );
168
- }
169
-
170
- ```
171
- ```ts title="src/routes/login/page.tsx"
172
- import { useLocation, useNavigate } from '@modern-js/runtime/router';
173
- import { useAuth } from '../Auth';
174
-
175
- export default function Login() {
176
- const navigate = useNavigate();
177
- const location = useLocation();
178
- const auth = useAuth();
179
-
180
- const from = location.state?.from?.pathname || '/';
181
-
182
- function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
183
- event.preventDefault();
184
-
185
- const formData = new FormData(event.currentTarget);
186
- const username = formData.get('username') as string;
187
-
188
- auth.signin(username, () => {
189
- // Send them back to the page they tried to visit when they were
190
- // redirected to the login page. Use { replace: true } so we don't create
191
- // another entry in the history stack for the login page. This means that
192
- // when they get to the protected page and click the back button, they
193
- // won't end up back on the login page, which is also really nice for the
194
- // user experience.
195
- navigate(from, { replace: true });
196
- });
197
- }
198
-
199
- return (
200
- <div>
201
- <p>You must log in to view the page at {from}</p>
202
-
203
- <form onSubmit={handleSubmit}>
204
- <label>
205
- Username: <input name="username" type="text" />
206
- </label>{' '}
207
- <button type="submit">Login</button>
208
- </form>
209
- </div>
210
- );
211
- }
212
-
213
- ```
214
31
  </Sandpack>
@@ -154,7 +154,7 @@ pnpm 暂不支持使用 JSON 字符串作为参数值,可使用 `npm new` 开
154
154
 
155
155
  :::
156
156
 
157
- import ServeCommand from "@site-docs/components/serve-command";
157
+ import ServeCommand from '@site-docs/components/serve-command';
158
158
 
159
159
  <ServeCommand />
160
160
 
@@ -175,7 +175,7 @@ Options:
175
175
 
176
176
  ## modern inspect
177
177
 
178
- `modern inspect` 命令用于查看项目的 [Rsbuild 配置](https://rsbuild.dev/zh/config/index) 以及 webpack 或 Rspack 配置。
178
+ `modern inspect` 命令用于查看项目的 [Rsbuild 配置](https://rsbuild.rs/zh/config/index) 以及 webpack 或 Rspack 配置。
179
179
 
180
180
  ```bash
181
181
  Usage: modern inspect [options]
@@ -232,6 +232,6 @@ Inspect config succeed, open following files to view the content:
232
232
  - Webpack Config (node): /root/my-project/dist/webpack.config.node.mjs
233
233
  ```
234
234
 
235
- import DeployCommand from "@site-docs/components/deploy-command";
235
+ import DeployCommand from '@site-docs/components/deploy-command';
236
236
 
237
237
  <DeployCommand />
@@ -80,7 +80,7 @@ title: Modern.js v2 发布
80
80
 
81
81
  目前,Rspack 项目以及 Modern.js 的 Rspack 模式仍在快速迭代中。在未来几个月内,我们将逐步对齐 Webpack 模式和 Rspack 模式的绝大多数功能和配置,使更多项目能从 Webpack 平滑地过渡到 Rspack。
82
82
 
83
- > Rspack 已于 2023.03.10 号正式开源,你也可以在非 Modern.js 的项目中直接使用 Rspack 进行构建。如果你对 Rspack 感兴趣,请阅读 [「Rspack 正式发布了」](https://www.rspack.dev/zh/blog/announcement.html)来了解更多。
83
+ > Rspack 已于 2023.03.10 号正式开源,你也可以在非 Modern.js 的项目中直接使用 Rspack 进行构建。如果你对 Rspack 感兴趣,请阅读 [「Rspack 正式发布了」](https://rspack.rs/zh/blog/announcement.html)来了解更多。
84
84
 
85
85
  ### 渐进式设计
86
86
 
@@ -224,7 +224,7 @@ Rspress 是一个面向文档站场景的框架,它的目标是给开发者提
224
224
 
225
225
  我们做 Rspress 的初心,是为了解决我们团队内的文档站搭建需求。随着 Rspress 的功能逐渐完整,我们也将它开放给社区使用,使它能发挥更大的价值。
226
226
 
227
- 目前,Rspress 仍处于 beta 测试状态,相关源代码已经开放在 [Rspress 仓库](https://github.com/web-infra-dev/rspress) 中,并提供了基础的 [使用文档](https://rspress.dev/)。在未来,我们将继续投入,使之成为一个完成度更高的文档解决方案。
227
+ 目前,Rspress 仍处于 beta 测试状态,相关源代码已经开放在 [Rspress 仓库](https://github.com/web-infra-dev/rspress) 中,并提供了基础的 [使用文档](https://rspress.rs/)。在未来,我们将继续投入,使之成为一个完成度更高的文档解决方案。
228
228
 
229
229
  ## 致谢
230
230
 
@@ -189,7 +189,7 @@ root
189
189
  └─ module-doc # Modern.js Module 文档
190
190
  ```
191
191
 
192
- 文档站使用 Rspress 构建,文档内容可以使用 markdown 或 mdx 语法编写。详细使用方法可以参考 [Rspress 文档](https://rspress.dev/)。
192
+ 文档站使用 Rspress 构建,文档内容可以使用 markdown 或 mdx 语法编写。详细使用方法可以参考 [Rspress 文档](https://rspress.rs/)。
193
193
 
194
194
  Rspress 的源代码可以在 [这个仓库](https://github.com/web-infra-dev/rspress) 中找到。
195
195
 
@@ -1,3 +1,3 @@
1
1
  Builder 指的是 Modern.js 的构建层,它的目标是为 Modern.js 用户提供开箱即用的构建能力,并支持在 webpack 和 Rspack 间无缝切换。
2
2
 
3
- Modern.js `MAJOR_VERSION.46.0` 之前版本使用的是 `@modern-js/builder`, 从 `MAJOR_VERSION.46.0` 开始升级为 [Rsbuild](https://rsbuild.dev/)。
3
+ Modern.js `MAJOR_VERSION.46.0` 之前版本使用的是 `@modern-js/builder`, 从 `MAJOR_VERSION.46.0` 开始升级为 [Rsbuild](https://rsbuild.rs/)。
@@ -1,4 +1,3 @@
1
-
2
- 指 [webpack](https://webpack.js.org/)、[Rspack](https://www.rspack.dev/) 等模块打包工具。
1
+ 指 [webpack](https://webpack.js.org/)、[Rspack](https://rspack.rs/) 等模块打包工具。
3
2
 
4
3
  打包工具的主要目标是将 JavaScript、CSS 等文件打包在一起,打包后的文件可以在浏览器、Node.js 等环境中使用。当 Bundler 处理 Web 应用时,它会构建一个依赖关系图,其中包含应用需要的各个模块,然后将所有模块打包成一个或多个 bundle。
@@ -1,3 +1,3 @@
1
- [Rsbuild](https://rsbuild.dev/) 是一个基于 Rspack 的 web 构建工具,它的目标是为 Rspack 用户提供开箱即用的构建能力,使开发者能够在零配置的情况下启动一个 web 项目。
1
+ [Rsbuild](https://rsbuild.rs/) 是一个基于 Rspack 的 web 构建工具,它的目标是为 Rspack 用户提供开箱即用的构建能力,使开发者能够在零配置的情况下启动一个 web 项目。
2
2
 
3
3
  Rsbuild 集成了社区中基于 Rust 的高性能工具,包括 Rspack 和 SWC,以提供一流的构建速度和开发体验。
@@ -1,3 +1,3 @@
1
- [Rspack](https://www.rspack.dev/) 是一个基于 Rust 编写的高性能 JavaScript 打包工具, 它提供对 webpack 生态良好的兼容性,能够无缝替换 webpack, 并提供闪电般的构建速度。
1
+ [Rspack](https://rspack.rs/) 是一个基于 Rust 编写的高性能 JavaScript 打包工具, 它提供对 webpack 生态良好的兼容性,能够无缝替换 webpack, 并提供闪电般的构建速度。
2
2
 
3
3
  相较于 webpack,Rspack 的构建性能有明显提升,除了 Rust 带来的语言优势,这也来自于它的并行架构和增量编译等特性。经过 benchmark 验证,Rspack 可以带来 5 ~ 10 倍编译性能的提升。
@@ -2,5 +2,5 @@
2
2
 
3
3
  在使用 Rspack 前,你需要了解以下事项:
4
4
 
5
- - Rspack 能够兼容大部分 webpack 插件和几乎所有的 loaders,但仍有少数 webpack 插件暂时无法使用,详见 [Plugin 兼容](https://rspack.dev/zh/guide/compatibility/plugin)。
6
- - Rspack 默认基于 [SWC](https://rspack.dev/zh/guide/features/builtin-swc-loader) 进行代码编译和压缩,在个别情况下,你可能会遇到 SWC 在边界场景的 bug,可以通过 [SWC 的 issue](https://github.com/swc-project/swc/issues) 反馈。
5
+ - Rspack 能够兼容大部分 webpack 插件和几乎所有的 loaders,但仍有少数 webpack 插件暂时无法使用,详见 [Plugin 兼容](https://rspack.rs/zh/guide/compatibility/plugin)。
6
+ - Rspack 默认基于 [SWC](https://rspack.rs/zh/guide/features/builtin-swc-loader) 进行代码编译和压缩,在个别情况下,你可能会遇到 SWC 在边界场景的 bug,可以通过 [SWC 的 issue](https://github.com/swc-project/swc/issues) 反馈。
@@ -11,7 +11,7 @@ sidebar_position: 21
11
11
 
12
12
  Rsbuild 是 Modern.js 底层的构建工具,请阅读 [构建能力](/guides/concept/builder) 了解相关背景。
13
13
 
14
- 如果你想了解 Rsbuild 插件的编写方式,可以参考 [Rsbuild - 插件系统](https://rsbuild.dev/zh/plugins/dev/index)。
14
+ 如果你想了解 Rsbuild 插件的编写方式,可以参考 [Rsbuild - 插件系统](https://rsbuild.rs/zh/plugins/dev/index)。
15
15
 
16
16
  ## 注意事项
17
17
 
@@ -76,4 +76,4 @@ export default {
76
76
 
77
77
  如果 `cdn2.com` 的资源也请求失败,则会继续请求 `cdn3.com`。
78
78
 
79
- `assetsRetry` 是基于 Rsbuild 的 Assets Retry 插件实现的,并提供相同的配置项。你可以参考 [Rsbuild - Assets Retry 插件](https://rsbuild.dev/zh/plugins/list/plugin-assets-retry#%E9%80%89%E9%A1%B9) 来了解所有可用的配置项。
79
+ `assetsRetry` 是基于 Rsbuild 的 Assets Retry 插件实现的,并提供相同的配置项。你可以参考 [Rsbuild - Assets Retry 插件](https://rsbuild.rs/zh/plugins/list/plugin-assets-retry#%E9%80%89%E9%A1%B9) 来了解所有可用的配置项。
@@ -7,7 +7,7 @@ title: copy
7
7
  - **类型:** `Rspack.CopyRspackPluginOptions | Rspack.CopyRspackPluginOptions['patterns']`
8
8
  - **默认值:** `undefined`
9
9
 
10
- 将指定的文件或目录拷贝到构建输出目录中,基于 [rspack.CopyRspackPlugin](https://rspack.dev/zh/plugins/rspack/copy-rspack-plugin) 实现。
10
+ 将指定的文件或目录拷贝到构建输出目录中,基于 [rspack.CopyRspackPlugin](https://rspack.rs/zh/plugins/rspack/copy-rspack-plugin) 实现。
11
11
 
12
12
  import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
13
13
 
@@ -38,7 +38,7 @@ export default {
38
38
  };
39
39
  ```
40
40
 
41
- 需要注意的是,Rspack 的持久化缓存处于[实验性阶段](https://rspack.dev/zh/config/experiments#experimentscache),可能会在未来的版本中发生变化,该功能需要手动开启。
41
+ 需要注意的是,Rspack 的持久化缓存处于[实验性阶段](https://rspack.rs/zh/config/experiments#experimentscache),可能会在未来的版本中发生变化,该功能需要手动开启。
42
42
 
43
43
  import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
44
44
 
@@ -4,9 +4,12 @@ title: transformLodash
4
4
 
5
5
  # performance.transformLodash
6
6
 
7
+ import { Badge } from '@theme';
8
+
9
+ <Badge type="danger" ><div>仅支持 Webpack</div></Badge>
10
+
7
11
  - **类型:** `boolean`
8
12
  - **默认值:** `true`
9
- - **打包工具:** `仅支持 webpack`
10
13
 
11
14
  是否模块化 [lodash](https://www.npmjs.com/package/lodash) 的导入,删除未使用的 lodash 模块,从而减少 lodash 代码体积。
12
15
 
@@ -19,7 +19,7 @@ type SriOptions = {
19
19
  为 HTML 所引入的 `<script>` 和 `<link rel="stylesheet">` 标签添加完整性属性 —— `integrity`,使浏览器能够验证引入资源的完整性,以此防止下载的资源被篡改。
20
20
 
21
21
  :::info
22
- SRI 的具体介绍可以参考 [Rsbuild security.sri](https://rsbuild.dev/zh/config/security/sri)。
22
+ SRI 的具体介绍可以参考 [Rsbuild security.sri](https://rsbuild.rs/zh/config/security/sri)。
23
23
 
24
24
  该配置类型和 Rsbuild 不完全一致,在构建时将自动进行转换。
25
25
  :::
@@ -4,10 +4,10 @@ title: exclude
4
4
 
5
5
  # source.exclude
6
6
 
7
- - **类型:** [RuleSetCondition[]](https://rspack.dev/zh/config/module#condition)
7
+ - **类型:** [RuleSetCondition[]](https://rspack.rs/zh/config/module#condition)
8
8
  - **默认值:** `[]`
9
9
 
10
- 指定不需要编译的 JavaScript/TypeScript 文件。用法与 Rspack 中的 [Rule.exclude](https://rspack.dev/zh/config/module#ruleexclude) 一致,支持传入字符串或正则表达式来匹配模块的路径。
10
+ 指定不需要编译的 JavaScript/TypeScript 文件。用法与 Rspack 中的 [Rule.exclude](https://rspack.rs/zh/config/module#ruleexclude) 一致,支持传入字符串或正则表达式来匹配模块的路径。
11
11
 
12
12
  import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
13
13
 
@@ -4,7 +4,7 @@ title: include
4
4
 
5
5
  # source.include
6
6
 
7
- - **类型:** [RuleSetCondition[]](https://rspack.dev/zh/config/module#condition)
7
+ - **类型:** [RuleSetCondition[]](https://rspack.rs/zh/config/module#condition)
8
8
  - **默认值:**
9
9
 
10
10
  ```ts
@@ -4,9 +4,12 @@ title: moduleScopes
4
4
 
5
5
  # source.moduleScopes
6
6
 
7
+ import { Badge } from '@theme';
8
+
9
+ <Badge type="danger" >仅支持 Webpack</Badge>
10
+
7
11
  - **类型:** `Array<string | Regexp> | Function`
8
12
  - **默认值:** `undefined`
9
- - **打包工具:** `仅支持 webpack`
10
13
 
11
14
  限制源代码的引用路径。配置该选项后,所有源文件只能从约定的目录下引用代码,从其他目录引用代码会产生对应的报错提示。
12
15
 
@@ -74,12 +74,12 @@ export default {
74
74
  };
75
75
  ```
76
76
 
77
- 你也可以使用 `transformImport` 的 [function 用法](https://rsbuild.dev/zh/config/source/transform-import#function-%E7%B1%BB%E5%9E%8B) 对默认配置进行自定义修改。
77
+ 你也可以使用 `transformImport` 的 [function 用法](https://rsbuild.rs/zh/config/source/transform-import#function-%E7%B1%BB%E5%9E%8B) 对默认配置进行自定义修改。
78
78
 
79
79
  ```js
80
80
  export default {
81
81
  source: {
82
- transformImport: (imports) => {
82
+ transformImport: imports => {
83
83
  return imports.filter(data => data.libraryName !== 'antd');
84
84
  },
85
85
  },
@@ -159,7 +159,7 @@ export default {
159
159
  tools: {
160
160
  babel(config, { modifyPresetEnvOptions }) {
161
161
  modifyPresetEnvOptions({
162
- targets: "last 2 versions",
162
+ targets: 'last 2 versions',
163
163
  });
164
164
  },
165
165
  },
@@ -172,9 +172,9 @@ export default {
172
172
  babel(config, { modifyPresetEnvOptions }) {
173
173
  modifyPresetEnvOptions({
174
174
  targets: {
175
- chrome: "58",
176
- ie: "11"
177
- }
175
+ chrome: '58',
176
+ ie: '11',
177
+ },
178
178
  });
179
179
  },
180
180
  },
@@ -209,7 +209,7 @@ export default {
209
209
 
210
210
  ### 调试 Babel 配置
211
211
 
212
- 当你通过 `tools.babel` 修改 `babel-loader` 配置后,可以在 [调试模式](https://rsbuild.dev/zh/guide/debug/debug-mode) 下查看最终生成的配置。
212
+ 当你通过 `tools.babel` 修改 `babel-loader` 配置后,可以在 [调试模式](https://rsbuild.rs/zh/guide/debug/debug-mode) 下查看最终生成的配置。
213
213
 
214
214
  首先通过 `DEBUG=builder` 参数开启调试模式:
215
215
 
@@ -222,4 +222,3 @@ DEBUG=builder pnpm build
222
222
  ```
223
223
 
224
224
  然后打开生成的 `(webpack|rspack).config.web.js`,搜索 `babel-loader` 关键词,即可看到完整的 `babel-loader` 配置内容。
225
-
@@ -24,10 +24,10 @@ type BundlerChainFn = (
24
24
 
25
25
  Bundler chain 是 webpack chain 的子集,其中包含一部分 webpack chain API,你可以用它来同时修改 webpack 和 Rspack 的配置。
26
26
 
27
- 通过 bundler chain 修改的配置,在 webpack 和 Rspack 构建时均可生效。需要注意的是,bundler chain 只支持修改 webpack 和 Rspack 间无差异部分的配置。如,修改 devtool 配置项(webpack 和 Rspack 的 devtool 属性值类型相同),或添加一个[Rspack 兼容](https://rspack.dev/zh/guide/compatibility/plugin)的 webpack 插件。
27
+ 通过 bundler chain 修改的配置,在 webpack 和 Rspack 构建时均可生效。需要注意的是,bundler chain 只支持修改 webpack 和 Rspack 间无差异部分的配置。如,修改 devtool 配置项(webpack 和 Rspack 的 devtool 属性值类型相同),或添加一个[Rspack 兼容](https://rspack.rs/zh/guide/compatibility/plugin)的 webpack 插件。
28
28
 
29
29
  :::
30
30
 
31
31
  > `tools.bundlerChain` 的执行时机早于 tools.webpackChain / tools.webpack / tools.rspack,因此会被其他几个配置中的修改所覆盖。
32
32
 
33
- 更多信息可参考 [Rsbuild#tools.bundlerChain](https://rsbuild.dev/zh/config/tools/bundler-chain)。
33
+ 更多信息可参考 [Rsbuild#tools.bundlerChain](https://rsbuild.rs/zh/config/tools/bundler-chain)。
@@ -27,7 +27,7 @@ const defaultOptions = {
27
27
  };
28
28
  ```
29
29
 
30
- 通过 `tools.cssExtract` 可以更改 [CssExtractRspackPlugin](https://www.rspack.dev/zh/plugins/rspack/css-extract-rspack-plugin) 或 [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的配置。
30
+ 通过 `tools.cssExtract` 可以更改 [CssExtractRspackPlugin](https://rspack.rs/zh/plugins/rspack/css-extract-rspack-plugin) 或 [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) 的配置。
31
31
 
32
32
  import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
33
33
 
@@ -10,7 +10,7 @@ title: devServer
10
10
  通过 `tools.devServer` 可以修改开发环境服务器的配置。
11
11
 
12
12
  :::tip
13
- Modern.js 中并没有直接使用 [webpack-dev-server](https://webpack.js.org/api/webpack-dev-server/) 或 [@rspack/dev-server](https://www.rspack.dev/guide/dev-server.html), 而是基于 [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) 实现 DevServer。
13
+ Modern.js 中并没有直接使用 [webpack-dev-server](https://webpack.js.org/api/webpack-dev-server/) 或 [@rspack/dev-server](https://rspack.rs/guide/dev-server.html), 而是基于 [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) 实现 DevServer。
14
14
  :::
15
15
 
16
16
  ### 选项
@@ -8,7 +8,7 @@ title: lightningcssLoader
8
8
  - **默认值:** `false`
9
9
  - **打包工具:** `仅支持 rspack`
10
10
 
11
- 通过 `tools.lightningcssLoader` 可以设置 [builtin:lightningcss-loader](https://rspack.dev/guide/features/builtin-lightningcss-loader) 的选项。
11
+ 通过 `tools.lightningcssLoader` 可以设置 [builtin:lightningcss-loader](https://rspack.rs/guide/features/builtin-lightningcss-loader) 的选项。
12
12
 
13
13
  ## 开启 loader
14
14
 
@@ -7,7 +7,7 @@ title: rspack
7
7
  - **类型:** `Rspack.Configuration | Function | undefined`
8
8
  - **默认值:** `undefined`
9
9
 
10
- `tools.rspack` 选项用于修改 [Rspack](https://rspack.dev/) 的配置项。
10
+ `tools.rspack` 选项用于修改 [Rspack](https://rspack.rs/) 的配置项。
11
11
 
12
12
  import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
13
13
 
@@ -19,7 +19,7 @@ import SWC from '@site-docs/components/swc.mdx';
19
19
 
20
20
  ## 在 Rspack 模式下使用
21
21
 
22
- 通过 `tools.swc` 可以设置 Rspack [builtin:swc-loader](https://rspack.dev/zh/guide/features/builtin-swc-loader) 的选项。
22
+ 通过 `tools.swc` 可以设置 Rspack [builtin:swc-loader](https://rspack.rs/zh/guide/features/builtin-swc-loader) 的选项。
23
23
 
24
24
  ```ts
25
25
  import { defineConfig } from '@modern-js/app-tools';
@@ -35,7 +35,7 @@ export default defineConfig<'rspack'>({
35
35
  });
36
36
  ```
37
37
 
38
- 更多用法可参考 [Rsbuild - tools.swc](https://rsbuild.dev/zh/config/tools/swc)。
38
+ 更多用法可参考 [Rsbuild - tools.swc](https://rsbuild.rs/zh/config/tools/swc)。
39
39
 
40
40
  ### 注册 SWC 插件
41
41
 
@@ -66,7 +66,7 @@ export default {
66
66
 
67
67
  如果你遇到了以上问题,通常可行的解决方法是将 Modern.js 和 SWC 插件都升级到最新版本。
68
68
 
69
- 详情可参考 [Rsbuild - SWC 插件版本](https://rsbuild.dev/zh/guide/basic/configure-swc#swc-%E6%8F%92%E4%BB%B6%E7%89%88%E6%9C%AC)。
69
+ 详情可参考 [Rsbuild - SWC 插件版本](https://rsbuild.rs/zh/guide/basic/configure-swc#swc-%E6%8F%92%E4%BB%B6%E7%89%88%E6%9C%AC)。
70
70
 
71
71
  ## 在 Webpack 模式下使用
72
72
 
@@ -4,6 +4,10 @@ title: terser
4
4
 
5
5
  # tools.terser
6
6
 
7
+ import { Badge } from '@theme';
8
+
9
+ <Badge type="danger" >仅支持 Webpack</Badge>
10
+
7
11
  - **类型:** `Object | Function | undefined`
8
12
  - **默认值:**
9
13
 
@@ -17,8 +21,6 @@ const defaultTerserOptions = {
17
21
  };
18
22
  ```
19
23
 
20
- - **打包工具:** `仅支持 webpack`
21
-
22
24
  在生产环境构建时,Modern.js 会通过 [terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin) 对 JavaScript 代码进行压缩优化。可以通过 `tools.terser` 修改 [terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin) 的配置。
23
25
 
24
26
  ### Object 类型
@@ -4,9 +4,12 @@ title: tsLoader
4
4
 
5
5
  # tools.tsLoader
6
6
 
7
+ import { Badge } from '@theme';
8
+
9
+ <Badge type="danger" >仅支持 Webpack</Badge>
10
+
7
11
  - **类型:** `Object | Function | undefined`
8
12
  - **默认值:** `undefined`
9
- - **打包工具:** `仅支持 webpack`
10
13
 
11
14
  :::warning 废弃提示
12
15