@modern-js/main-doc 0.0.0-nightly-20240826170723 → 0.0.0-nightly-20240827170702
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.
- package/docs/en/community/blog/_meta.json +1 -6
- package/docs/en/configure/_meta.json +1 -1
- package/docs/en/configure/app/tools/swc.mdx +1 -1
- package/docs/en/guides/advanced-features/bff/_meta.json +1 -6
- package/docs/en/guides/advanced-features/rspack-start.mdx +1 -8
- package/docs/en/guides/advanced-features/ssr/_meta.json +1 -5
- package/docs/en/guides/basic-features/data/_meta.json +1 -4
- package/docs/en/guides/basic-features/data/data-fetch.mdx +1 -1
- package/docs/en/guides/concept/_meta.json +1 -4
- package/docs/en/guides/get-started/_meta.json +1 -7
- package/docs/en/guides/topic-detail/framework-plugin/_meta.json +1 -1
- package/docs/en/guides/topic-detail/generator/_meta.json +1 -1
- package/docs/en/guides/topic-detail/generator/create/_meta.json +1 -5
- package/docs/en/guides/topic-detail/generator/new/_meta.json +1 -5
- package/docs/en/guides/topic-detail/generator/plugin/_meta.json +1 -1
- package/docs/en/guides/troubleshooting/_meta.json +1 -6
- package/docs/zh/community/blog/_meta.json +1 -6
- package/docs/zh/configure/_meta.json +1 -1
- package/docs/zh/configure/app/tools/swc.mdx +1 -1
- package/docs/zh/guides/advanced-features/bff/_meta.json +1 -6
- package/docs/zh/guides/advanced-features/rspack-start.mdx +1 -8
- package/docs/zh/guides/advanced-features/ssr/_meta.json +1 -5
- package/docs/zh/guides/basic-features/data/_meta.json +1 -4
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +1 -2
- package/docs/zh/guides/concept/_meta.json +1 -4
- package/docs/zh/guides/get-started/_meta.json +1 -7
- package/docs/zh/guides/topic-detail/framework-plugin/_meta.json +1 -1
- package/docs/zh/guides/topic-detail/generator/_meta.json +1 -1
- package/docs/zh/guides/topic-detail/generator/create/_meta.json +1 -5
- package/docs/zh/guides/topic-detail/generator/new/_meta.json +1 -5
- package/docs/zh/guides/topic-detail/generator/plugin/_meta.json +1 -1
- package/docs/zh/guides/troubleshooting/_meta.json +1 -6
- package/package.json +4 -4
- package/rspress.config.ts +1 -1
- package/src/components/ContentCard/index.tsx +1 -1
- package/src/components/Sandpack/index.tsx +1 -1
- package/src/components/ShowcaseList/index.tsx +1 -1
- package/src/i18n/index.ts +1 -1
- package/src/pages/index.tsx +2 -2
@@ -19,7 +19,7 @@ When using Rspack as the bundler, SWC will be used for transpiling and compressi
|
|
19
19
|
|
20
20
|
## Used in Rspack mode
|
21
21
|
|
22
|
-
You can set the options of [builtin:swc-loader](https://
|
22
|
+
You can set the options of [builtin:swc-loader](https://rspack.dev/guide/features/builtin-swc-loader) through `tools.swc`.
|
23
23
|
|
24
24
|
```
|
25
25
|
import { defineConfig } from '@modern-js/app-tools';
|
@@ -22,13 +22,6 @@ import InitRspackApp from '@site-docs-en/components/init-rspack-app';
|
|
22
22
|
|
23
23
|
After the project is created, you can experience the project by running `pnpm run dev`. For more project information, please refer to [Quick Start](/guides/get-started/quick-start.html).
|
24
24
|
|
25
|
-
:::tip
|
26
|
-
When using Rspack as the bundler, the following Features are temporarily unavailable as some of the capabilities are still under development and we will provide support in the future.
|
27
|
-
|
28
|
-
- The usage of [useLoader](/guides/basic-features/data/data-fetch.html) in Client Side Rendering
|
29
|
-
|
30
|
-
:::
|
31
|
-
|
32
25
|
## Enable Rspack build
|
33
26
|
|
34
27
|
Since Modern.js MAJOR_VERSION.46.0, you can enable Rspack build by add the following configuration in `modern.config.ts`:
|
@@ -85,7 +78,7 @@ For unsupported configurations, we have marked `Bundler: only support webpack` o
|
|
85
78
|
|
86
79
|
## Modify transpile configuration
|
87
80
|
|
88
|
-
Modern.js uses Rspack [builtin:swc-loader](https://
|
81
|
+
Modern.js uses Rspack [builtin:swc-loader](https://rspack.dev/guide/features/builtin-swc-loader) for code translation in Rspack mode.
|
89
82
|
|
90
83
|
Modern.js has provided a more convenient configuration for the common configuration of `builtin:swc-loader`, such as: configuring the component library to import it on demand through [source.transformImport](/configure/app/source/transform-import).
|
91
84
|
|
@@ -481,7 +481,7 @@ The Data Loader in our SSR project is designed to only run on the server side. T
|
|
481
481
|
**`useLoader`** is a legacy API in Modern.js v1. This API is a React Hook designed specifically for SSR applications, allowing developers to fetch data in components in isomorphic development.
|
482
482
|
|
483
483
|
:::tip
|
484
|
-
It is not necessary to use `useLoader` to fetch data in CSR projects.
|
484
|
+
It is not necessary to use `useLoader` to fetch data in CSR projects, and `useLoader` is not supported when using Rspack as the bundler.
|
485
485
|
:::
|
486
486
|
|
487
487
|
Here is the simplest example:
|
@@ -19,7 +19,7 @@ import SWC from '@modern-js/builder-doc/docs/zh/shared/swc.md';
|
|
19
19
|
|
20
20
|
## 在 Rspack 模式下使用
|
21
21
|
|
22
|
-
通过 `tools.swc` 可以设置 Rspack [builtin:swc-loader](https://
|
22
|
+
通过 `tools.swc` 可以设置 Rspack [builtin:swc-loader](https://rspack.dev/zh/guide/features/builtin-swc-loader) 的选项。
|
23
23
|
|
24
24
|
```
|
25
25
|
import { defineConfig } from '@modern-js/app-tools';
|
@@ -22,13 +22,6 @@ import InitRspackApp from '@site-docs/components/init-rspack-app';
|
|
22
22
|
|
23
23
|
项目创建完成后,在项目中执行 `pnpm run dev` 即可体验项目,更多信息可参考[快速上手](/guides/get-started/quick-start.html)。
|
24
24
|
|
25
|
-
:::tip
|
26
|
-
在使用 Rspack 作为打包工具时,由于部分能力尚在开发中,以下 features 暂时无法使用,我们将在未来提供支持:
|
27
|
-
|
28
|
-
- 客户端渲染(CSR)使用 [useLoader](/guides/basic-features/data/data-fetch.html)
|
29
|
-
|
30
|
-
:::
|
31
|
-
|
32
25
|
## 开启 Rspack 构建
|
33
26
|
|
34
27
|
从 Modern.js MAJOR_VERSION.46.0 版本起,在一个已有的 Modern.js 项目中,你仅需在 `modern.config.ts` 中添加以下配置,即可启用 Rspack 构建:
|
@@ -86,7 +79,7 @@ export default {
|
|
86
79
|
|
87
80
|
## 修改转译配置
|
88
81
|
|
89
|
-
Modern.js 在 Rspack 模式下使用 Rspack [builtin:swc-loader](https://
|
82
|
+
Modern.js 在 Rspack 模式下使用 Rspack [builtin:swc-loader](https://rspack.dev/zh/guide/features/builtin-swc-loader) 进行代码转译。
|
90
83
|
|
91
84
|
Modern.js 已对 `builtin:swc-loader` 的常见配置提供了更方便的配置方式,如:通过 [source.transformImport](/configure/app/source/transform-import) 配置组件库按需引入。如果对 `builtin:swc-loader` 有自定义配置的需求,可通过 [tools.swc](/configure/app/tools/swc) 进行配置:
|
92
85
|
|
@@ -499,8 +499,7 @@ export const loader = async (): Promise<ProfileData> => {
|
|
499
499
|
**`useLoader`** 是 Modern.js 老版本中的 API。该 API 是一个 React Hook,专门提供给 SSR 应用使用,让开发者能同构的在组件中获取数据。
|
500
500
|
|
501
501
|
:::tip
|
502
|
-
CSR 的项目没有必要使用 `useLoader`
|
503
|
-
|
502
|
+
CSR 的项目没有必要使用 `useLoader` 获取数据,且在使用 Rspack 作为打包工具时,`useLoader` 不支持使用。
|
504
503
|
:::
|
505
504
|
|
506
505
|
以下是一个最简单的例子:
|
package/package.json
CHANGED
@@ -15,17 +15,17 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "0.0.0-nightly-
|
18
|
+
"version": "0.0.0-nightly-20240827170702",
|
19
19
|
"publishConfig": {
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
21
21
|
"access": "public",
|
22
22
|
"provenance": true
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@modern-js/sandpack-react": "0.0.0-nightly-
|
25
|
+
"@modern-js/sandpack-react": "0.0.0-nightly-20240827170702"
|
26
26
|
},
|
27
27
|
"peerDependencies": {
|
28
|
-
"@modern-js/builder-doc": "0.0.0-nightly-
|
28
|
+
"@modern-js/builder-doc": "0.0.0-nightly-20240827170702"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
31
|
"@rspress/shared": "1.27.0",
|
@@ -39,7 +39,7 @@
|
|
39
39
|
"rspress": "1.27.0",
|
40
40
|
"ts-node": "^10.9.1",
|
41
41
|
"typescript": "^5",
|
42
|
-
"@modern-js/builder-doc": "0.0.0-nightly-
|
42
|
+
"@modern-js/builder-doc": "0.0.0-nightly-20240827170702"
|
43
43
|
},
|
44
44
|
"scripts": {
|
45
45
|
"dev": "rspress dev",
|
package/rspress.config.ts
CHANGED
@@ -2,7 +2,7 @@ import ModernSandpack, {
|
|
2
2
|
type ModernSandpackProps,
|
3
3
|
} from '@modern-js/sandpack-react';
|
4
4
|
import React, { type PropsWithChildren } from 'react';
|
5
|
-
import {
|
5
|
+
import { NoSSR, useDark } from 'rspress/runtime';
|
6
6
|
|
7
7
|
import './index.css';
|
8
8
|
|
package/src/i18n/index.ts
CHANGED
package/src/pages/index.tsx
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
/* eslint-disable react/no-unescaped-entities */
|
2
2
|
import clsx from 'clsx';
|
3
|
-
import { useLang, Helmet, useLocation } from 'rspress/runtime';
|
4
3
|
import { useEffect } from 'react';
|
4
|
+
import { Helmet, useLang, useLocation } from 'rspress/runtime';
|
5
5
|
import ContentCard from '../components/ContentCard';
|
6
|
-
import SecondaryTitle from '../components/SecondaryTitle';
|
7
6
|
import { FeatureLayout } from '../components/FeatureLayout';
|
8
7
|
import Footer from '../components/Footer';
|
8
|
+
import SecondaryTitle from '../components/SecondaryTitle';
|
9
9
|
import { useI18n, useUrl } from '../i18n';
|
10
10
|
import styles from './index.module.scss';
|
11
11
|
|