@modern-js/main-doc 0.0.0-next-20230222140615 → 0.0.0-next-20230223050219

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-20230222140615
3
+ ## 0.0.0-next-20230223050219
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -19,4 +19,4 @@
19
19
  - Updated dependencies [88f7b340d]
20
20
  - Updated dependencies [107f674fd]
21
21
  - Updated dependencies [fae9d1bd8]
22
- - @modern-js/builder-doc@0.0.0-next-20230222140615
22
+ - @modern-js/builder-doc@0.0.0-next-20230223050219
@@ -0,0 +1,69 @@
1
+ ---
2
+ title: Rspack Start
3
+ sidebar_position: 12
4
+ ---
5
+
6
+ # Rspack Start
7
+
8
+ [Rspack](https://www.rspack.org/) is a Rust-based web bundler developed by the ByteDance Web Infra team. The core architecture of Rspack is aligned with the implementation of webpack, and provides out-of-the-box support for commonly used build features.
9
+
10
+ Rspack optimizes compilation performance by:
11
+
12
+ - Highly LTO optimized Native code.
13
+ - Take full advantage of multi-core, and the entire compilation process is fully optimized for multi-threading.
14
+ - On-demand compilation based on request (Lazy Compilation), reducing the number of modules per compilation to improve the speed of cold start.
15
+
16
+ ## Initializing an rspack project
17
+
18
+ The Modern.js generator provides an interactive question-and-answer interface to initialize a project. To create an rspack project, simply select the **rspack** build tool by running:
19
+
20
+ ```bash
21
+ $ npx @modern-js/create myapp
22
+ ? Please select the solution you want to create: Web App Solution
23
+ ? Development Language: TS
24
+ ? Package Management Tool: pnpm
25
+ ? Build Tools: rspack
26
+ ```
27
+
28
+ 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).
29
+
30
+ :::tip
31
+ When using rspack as the bundler, the following features are currently not supported:
32
+
33
+ - Server-side rendering (SSR)
34
+ - Static Site Generation (SSG)
35
+ - Micro Frontend.
36
+ - Storybook debugging.
37
+
38
+ :::
39
+
40
+ ## Migrating from webpack to rspack
41
+
42
+ You can enable rspack build by running `pnpm run new`:
43
+
44
+ ```bash
45
+ $ pnpm run new
46
+ ? Action: Enable features
47
+ ? Enable features: Enable rspack Build
48
+ ```
49
+
50
+ After executing the command, enable the rspack build in `modern.config.ts`:
51
+
52
+ ```ts title=modern.config.ts
53
+ import appTools, { defineConfig } from '@modern-js/app-tools';
54
+
55
+ export default defineConfig<'rspack'>({
56
+ runtime: {
57
+ router: true,
58
+ },
59
+ plugins: [
60
+ appTools({
61
+ bundler: 'experimental-rspack',
62
+ }),
63
+ ],
64
+ });
65
+ ```
66
+
67
+ :::tip
68
+ Migrating from webpack to rspack may have some differences in build and configuration capabilities. For more details, please refer to [Configuration Differences](https://modernjs.dev/builder/en/guide/advanced/rspack-start.html#migrating-from-webpack-to-rspack)
69
+ :::
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-next-20230222140615",
14
+ "version": "0.0.0-next-20230223050219",
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/",
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@modern-js/builder-doc": "0.0.0-next-20230222140615"
20
+ "@modern-js/builder-doc": "0.0.0-next-20230223050219"
21
21
  },
22
22
  "devDependencies": {
23
23
  "ts-node": "^10",
@@ -25,7 +25,7 @@
25
25
  "fs-extra": "^10",
26
26
  "@types/node": "^16",
27
27
  "@types/fs-extra": "^9",
28
- "@modern-js/builder-doc": "0.0.0-next-20230222140615"
28
+ "@modern-js/builder-doc": "0.0.0-next-20230223050219"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "npx ts-node ./scripts/sync.ts"
@@ -0,0 +1,69 @@
1
+ ---
2
+ title: 使用 Rspack
3
+ sidebar_position: 12
4
+ ---
5
+
6
+ # 使用 Rspack
7
+
8
+ [Rspack](https://www.rspack.org/) 是字节跳动 Web Infra 团队自研的 Rust Bundler,核心架构对齐 webpack 实现,并对社区常用的构建能力做了开箱即用的支持。
9
+
10
+ Rspack 通过以下方式来提升编译性能:
11
+
12
+ - 高度 LTO 优化的 Native code。
13
+ - 充分利用多核优势,整个编译过程充分进行多线程优化。
14
+ - 基于请求的按需编译(Lazy Compilation),减小每次编译的模块数目,以提升冷启动的速度。
15
+
16
+ ## 初始化 rspack 项目
17
+
18
+ Modern.js 生成器会提供一个可交互的问答界面,只需将构建工具选择为**rspack**,即可创建一个 rspack 项目:
19
+
20
+ ```bash
21
+ $ npx @modern-js/create myapp
22
+ ? 请选择你想创建的工程类型 应用
23
+ ? 请选择开发语言 TS
24
+ ? 请选择包管理工具 pnpm
25
+ ? 请选择构建工具 rspack
26
+ ```
27
+
28
+ 项目创建完成后,在项目中执行 `pnpm run dev` 即可体验项目。更多项目信息可参考[快速上手](/guides/get-started/quick-start.html)。
29
+
30
+ :::tip
31
+ 使用 rspack 作为打包工具时,以下功能暂不支持使用:
32
+
33
+ - 服务端渲染(SSR)
34
+ - 静态站点生成(SSG)
35
+ - 微前端(Micro Frontend)
36
+ - Storybook 调试
37
+
38
+ :::
39
+
40
+ ## 从 webpack 迁移至 rspack
41
+
42
+ 通过执行 `pnpm run new` 可启用 rspack 构建:
43
+
44
+ ```bash
45
+ $ pnpm run new
46
+ ? 请选择你想要的操作 启用可选功能
47
+ ? 启用可选功能 启用「rspack 构建」
48
+ ```
49
+
50
+ 执行命令后,在 modern.config.ts 中开启 rspack 构建:
51
+
52
+ ```ts title=modern.config.ts
53
+ import appTools, { defineConfig } from '@modern-js/app-tools';
54
+
55
+ export default defineConfig<'rspack'>({
56
+ runtime: {
57
+ router: true,
58
+ },
59
+ plugins: [
60
+ appTools({
61
+ bundler: 'experimental-rspack',
62
+ }),
63
+ ],
64
+ });
65
+ ```
66
+
67
+ :::tip
68
+ 从 webpack 迁移至 rspack,会有一些构建和配置能力上的差异,详情可参考:[配置差异](https://modernjs.dev/builder/guide/advanced/rspack-start.html#从-webpack-迁移到-rspack)
69
+ :::