@modern-js/main-doc 2.9.0 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +13 -0
- package/docs/en/apis/app/runtime/web-server/hook.mdx +1 -3
- package/docs/en/apis/app/runtime/web-server/middleware.mdx +1 -4
- package/docs/en/blog/index.md +8 -0
- package/docs/en/configure/app/output/splitRouteChunks.mdx +20 -0
- package/docs/en/guides/advanced-features/compatibility.mdx +1 -0
- package/docs/en/guides/advanced-features/rspack-start.mdx +1 -1
- package/docs/en/guides/get-started/introduction.mdx +1 -1
- package/docs/en/guides/get-started/quick-start.mdx +2 -0
- package/docs/en/guides/topic-detail/framework-plugin/plugin-api.mdx +29 -28
- package/docs/en/guides/topic-detail/generator/codesmith/api/fs.mdx +2 -2
- package/docs/zh/apis/app/runtime/web-server/hook.mdx +1 -3
- package/docs/zh/apis/app/runtime/web-server/middleware.mdx +1 -4
- package/docs/zh/blog/index.md +71 -3
- package/docs/zh/blog/updates/2022-0708-updates.md +96 -0
- package/docs/zh/blog/updates/2022-0910-updates.md +80 -0
- package/docs/zh/blog/updates/_category_.json +5 -0
- package/docs/zh/blog/updates/v2-release-note.mdx +250 -0
- package/docs/zh/configure/app/output/splitRouteChunks.mdx +20 -0
- package/docs/zh/guides/advanced-features/compatibility.mdx +1 -0
- package/docs/zh/guides/advanced-features/eslint.mdx +1 -1
- package/docs/zh/guides/advanced-features/rspack-start.mdx +1 -1
- package/docs/zh/guides/get-started/quick-start.mdx +2 -0
- package/docs/zh/guides/topic-detail/framework-plugin/plugin-api.mdx +30 -29
- package/docs/zh/guides/topic-detail/generator/codesmith/api/fs.mdx +2 -2
- package/modern.config.ts +5 -6
- package/package.json +5 -5
- package/src/pages/index.tsx +10 -5
- package/en/configure/app/dev/asset-prefix.mdx +0 -13
- package/en/configure/app/dev/before-start-url.mdx +0 -13
- package/en/configure/app/dev/hmr.mdx +0 -13
- package/en/configure/app/dev/host.mdx +0 -13
- package/en/configure/app/dev/https.mdx +0 -13
- package/en/configure/app/dev/port.mdx +0 -13
- package/en/configure/app/dev/progress-bar.mdx +0 -13
- package/en/configure/app/dev/start-url.mdx +0 -13
- package/en/configure/app/experiments/lazy-compilation.mdx +0 -13
- package/en/configure/app/html/app-icon.mdx +0 -13
- package/en/configure/app/html/crossorigin.mdx +0 -13
- package/en/configure/app/html/disable-html-folder.mdx +0 -13
- package/en/configure/app/html/favicon-by-entries.mdx +0 -13
- package/en/configure/app/html/favicon.mdx +0 -13
- package/en/configure/app/html/inject-by-entries.mdx +0 -13
- package/en/configure/app/html/inject.mdx +0 -13
- package/en/configure/app/html/meta-by-entries.mdx +0 -13
- package/en/configure/app/html/meta.mdx +0 -13
- package/en/configure/app/html/mount-id.mdx +0 -13
- package/en/configure/app/html/tags-by-entries.mdx +0 -13
- package/en/configure/app/html/tags.mdx +0 -13
- package/en/configure/app/html/template-by-entries.mdx +0 -13
- package/en/configure/app/html/template-parameters-by-entries.mdx +0 -13
- package/en/configure/app/html/template-parameters.mdx +0 -13
- package/en/configure/app/html/template.mdx +0 -13
- package/en/configure/app/html/title-by-entries.mdx +0 -13
- package/en/configure/app/html/title.mdx +0 -13
- package/en/configure/app/output/asset-prefix.mdx +0 -13
- package/en/configure/app/output/assets-retry.mdx +0 -13
- package/en/configure/app/output/charset.mdx +0 -13
- package/en/configure/app/output/clean-dist-path.mdx +0 -13
- package/en/configure/app/output/convert-to-rem.mdx +0 -13
- package/en/configure/app/output/copy.mdx +0 -13
- package/en/configure/app/output/css-module-local-ident-name.mdx +0 -13
- package/en/configure/app/output/data-uri-limit.mdx +0 -13
- package/en/configure/app/output/disable-css-extract.mdx +0 -13
- package/en/configure/app/output/disable-css-module-extension.mdx +0 -13
- package/en/configure/app/output/disable-filename-hash.mdx +0 -13
- package/en/configure/app/output/disable-inline-runtime-chunk.mdx +0 -13
- package/en/configure/app/output/disable-minimize.mdx +0 -13
- package/en/configure/app/output/disable-source-map.mdx +0 -13
- package/en/configure/app/output/disable-ts-checker.mdx +0 -13
- package/en/configure/app/output/dist-path.mdx +0 -13
- package/en/configure/app/output/enable-asset-fallback.mdx +0 -13
- package/en/configure/app/output/enable-asset-manifest.mdx +0 -13
- package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +0 -13
- package/en/configure/app/output/enable-inline-scripts.mdx +0 -13
- package/en/configure/app/output/enable-inline-styles.mdx +0 -13
- package/en/configure/app/output/enable-latest-decorators.mdx +0 -13
- package/en/configure/app/output/externals.mdx +0 -13
- package/en/configure/app/output/filename.mdx +0 -13
- package/en/configure/app/output/legal-comments.mdx +0 -13
- package/en/configure/app/output/override-browserslist.mdx +0 -13
- package/en/configure/app/output/polyfill.mdx +0 -13
- package/en/configure/app/output/svg-default-export.mdx +0 -13
- package/en/configure/app/performance/build-cache.mdx +0 -13
- package/en/configure/app/performance/bundle-analyze.mdx +0 -13
- package/en/configure/app/performance/chunk-split.mdx +0 -13
- package/en/configure/app/performance/print-file-size.mdx +0 -13
- package/en/configure/app/performance/profile.mdx +0 -13
- package/en/configure/app/performance/remove-console.mdx +0 -13
- package/en/configure/app/performance/remove-moment-locale.mdx +0 -13
- package/en/configure/app/security/check-syntax.mdx +0 -13
- package/en/configure/app/security/sri.mdx +0 -13
- package/en/configure/app/source/alias.mdx +0 -13
- package/en/configure/app/source/compile-js-data-uri.mdx +0 -13
- package/en/configure/app/source/define.mdx +0 -13
- package/en/configure/app/source/exclude.mdx +0 -13
- package/en/configure/app/source/global-vars.mdx +0 -13
- package/en/configure/app/source/include.mdx +0 -13
- package/en/configure/app/source/module-scopes.mdx +0 -13
- package/en/configure/app/source/pre-entry.mdx +0 -13
- package/en/configure/app/source/resolve-extension-prefix.mdx +0 -13
- package/en/configure/app/source/resolve-main-fields.mdx +0 -13
- package/en/configure/app/tools/autoprefixer.mdx +0 -13
- package/en/configure/app/tools/babel.mdx +0 -13
- package/en/configure/app/tools/css-extract.mdx +0 -13
- package/en/configure/app/tools/css-loader.mdx +0 -13
- package/en/configure/app/tools/dev-server.mdx +0 -13
- package/en/configure/app/tools/html-plugin.mdx +0 -13
- package/en/configure/app/tools/inspector.mdx +0 -13
- package/en/configure/app/tools/less.mdx +0 -13
- package/en/configure/app/tools/minify-css.mdx +0 -13
- package/en/configure/app/tools/postcss.mdx +0 -13
- package/en/configure/app/tools/pug.mdx +0 -13
- package/en/configure/app/tools/rspack.mdx +0 -13
- package/en/configure/app/tools/sass.mdx +0 -13
- package/en/configure/app/tools/style-loader.mdx +0 -13
- package/en/configure/app/tools/styled-components.mdx +0 -13
- package/en/configure/app/tools/terser.mdx +0 -13
- package/en/configure/app/tools/ts-checker.mdx +0 -13
- package/en/configure/app/tools/ts-loader.mdx +0 -13
- package/en/configure/app/tools/webpack-chain.mdx +0 -13
- package/en/configure/app/tools/webpack.mdx +0 -13
- package/zh/configure/app/dev/asset-prefix.mdx +0 -13
- package/zh/configure/app/dev/before-start-url.mdx +0 -13
- package/zh/configure/app/dev/hmr.mdx +0 -13
- package/zh/configure/app/dev/host.mdx +0 -13
- package/zh/configure/app/dev/https.mdx +0 -13
- package/zh/configure/app/dev/port.mdx +0 -13
- package/zh/configure/app/dev/progress-bar.mdx +0 -13
- package/zh/configure/app/dev/start-url.mdx +0 -13
- package/zh/configure/app/experiments/lazy-compilation.mdx +0 -13
- package/zh/configure/app/html/app-icon.mdx +0 -13
- package/zh/configure/app/html/crossorigin.mdx +0 -13
- package/zh/configure/app/html/disable-html-folder.mdx +0 -13
- package/zh/configure/app/html/favicon-by-entries.mdx +0 -13
- package/zh/configure/app/html/favicon.mdx +0 -13
- package/zh/configure/app/html/inject-by-entries.mdx +0 -13
- package/zh/configure/app/html/inject.mdx +0 -13
- package/zh/configure/app/html/meta-by-entries.mdx +0 -13
- package/zh/configure/app/html/meta.mdx +0 -13
- package/zh/configure/app/html/mount-id.mdx +0 -13
- package/zh/configure/app/html/tags-by-entries.mdx +0 -13
- package/zh/configure/app/html/tags.mdx +0 -13
- package/zh/configure/app/html/template-by-entries.mdx +0 -13
- package/zh/configure/app/html/template-parameters-by-entries.mdx +0 -13
- package/zh/configure/app/html/template-parameters.mdx +0 -13
- package/zh/configure/app/html/template.mdx +0 -13
- package/zh/configure/app/html/title-by-entries.mdx +0 -13
- package/zh/configure/app/html/title.mdx +0 -13
- package/zh/configure/app/output/asset-prefix.mdx +0 -13
- package/zh/configure/app/output/assets-retry.mdx +0 -13
- package/zh/configure/app/output/charset.mdx +0 -13
- package/zh/configure/app/output/clean-dist-path.mdx +0 -13
- package/zh/configure/app/output/convert-to-rem.mdx +0 -13
- package/zh/configure/app/output/copy.mdx +0 -13
- package/zh/configure/app/output/css-module-local-ident-name.mdx +0 -13
- package/zh/configure/app/output/data-uri-limit.mdx +0 -13
- package/zh/configure/app/output/disable-css-extract.mdx +0 -13
- package/zh/configure/app/output/disable-css-module-extension.mdx +0 -13
- package/zh/configure/app/output/disable-filename-hash.mdx +0 -13
- package/zh/configure/app/output/disable-inline-runtime-chunk.mdx +0 -13
- package/zh/configure/app/output/disable-minimize.mdx +0 -13
- package/zh/configure/app/output/disable-source-map.mdx +0 -13
- package/zh/configure/app/output/disable-ts-checker.mdx +0 -13
- package/zh/configure/app/output/dist-path.mdx +0 -13
- package/zh/configure/app/output/enable-asset-fallback.mdx +0 -13
- package/zh/configure/app/output/enable-asset-manifest.mdx +0 -13
- package/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +0 -13
- package/zh/configure/app/output/enable-inline-scripts.mdx +0 -13
- package/zh/configure/app/output/enable-inline-styles.mdx +0 -13
- package/zh/configure/app/output/enable-latest-decorators.mdx +0 -13
- package/zh/configure/app/output/externals.mdx +0 -13
- package/zh/configure/app/output/filename.mdx +0 -13
- package/zh/configure/app/output/legal-comments.mdx +0 -13
- package/zh/configure/app/output/override-browserslist.mdx +0 -13
- package/zh/configure/app/output/polyfill.mdx +0 -13
- package/zh/configure/app/output/svg-default-export.mdx +0 -13
- package/zh/configure/app/performance/build-cache.mdx +0 -13
- package/zh/configure/app/performance/bundle-analyze.mdx +0 -13
- package/zh/configure/app/performance/chunk-split.mdx +0 -13
- package/zh/configure/app/performance/print-file-size.mdx +0 -13
- package/zh/configure/app/performance/profile.mdx +0 -13
- package/zh/configure/app/performance/remove-console.mdx +0 -13
- package/zh/configure/app/performance/remove-moment-locale.mdx +0 -13
- package/zh/configure/app/security/check-syntax.mdx +0 -13
- package/zh/configure/app/security/sri.mdx +0 -13
- package/zh/configure/app/source/alias.mdx +0 -13
- package/zh/configure/app/source/compile-js-data-uri.mdx +0 -13
- package/zh/configure/app/source/define.mdx +0 -13
- package/zh/configure/app/source/exclude.mdx +0 -13
- package/zh/configure/app/source/global-vars.mdx +0 -13
- package/zh/configure/app/source/include.mdx +0 -13
- package/zh/configure/app/source/module-scopes.mdx +0 -13
- package/zh/configure/app/source/pre-entry.mdx +0 -13
- package/zh/configure/app/source/resolve-extension-prefix.mdx +0 -13
- package/zh/configure/app/source/resolve-main-fields.mdx +0 -13
- package/zh/configure/app/tools/autoprefixer.mdx +0 -13
- package/zh/configure/app/tools/babel.mdx +0 -13
- package/zh/configure/app/tools/css-extract.mdx +0 -13
- package/zh/configure/app/tools/css-loader.mdx +0 -13
- package/zh/configure/app/tools/dev-server.mdx +0 -13
- package/zh/configure/app/tools/html-plugin.mdx +0 -13
- package/zh/configure/app/tools/inspector.mdx +0 -13
- package/zh/configure/app/tools/less.mdx +0 -13
- package/zh/configure/app/tools/minify-css.mdx +0 -13
- package/zh/configure/app/tools/postcss.mdx +0 -13
- package/zh/configure/app/tools/pug.mdx +0 -13
- package/zh/configure/app/tools/rspack.mdx +0 -13
- package/zh/configure/app/tools/sass.mdx +0 -13
- package/zh/configure/app/tools/style-loader.mdx +0 -13
- package/zh/configure/app/tools/styled-components.mdx +0 -13
- package/zh/configure/app/tools/terser.mdx +0 -13
- package/zh/configure/app/tools/ts-checker.mdx +0 -13
- package/zh/configure/app/tools/ts-loader.mdx +0 -13
- package/zh/configure/app/tools/webpack-chain.mdx +0 -13
- package/zh/configure/app/tools/webpack.mdx +0 -13
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# @modern-js/main-doc
|
2
2
|
|
3
|
+
## 2.10.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 92d247f: fix: support tools.devServer.header include string[] type, remove get & delete & apply api in hook or middleware api
|
8
|
+
fix: 支持 tools.devServer.header 包含字符串数组类型,移除 Hook 和 Middleware 中对 响应 Cookie 的获取、删除操作
|
9
|
+
- 19e552a: fix: main doc theme
|
10
|
+
|
11
|
+
fix: 首页深色模式问题
|
12
|
+
|
13
|
+
- Updated dependencies [cfdbf80]
|
14
|
+
- @modern-js/builder-doc@2.10.0
|
15
|
+
|
3
16
|
## 2.9.0
|
4
17
|
|
5
18
|
### Patch Changes
|
@@ -38,9 +38,7 @@ type HookContext = {
|
|
38
38
|
set: (key: string, value: string) => void;
|
39
39
|
status: (code: number) => void;
|
40
40
|
cookies: {
|
41
|
-
|
42
|
-
set: (key: string, value: string) => void;
|
43
|
-
delete: () => void;
|
41
|
+
set: (key: string, value: string, options?: any) => void;
|
44
42
|
clear: () => void;
|
45
43
|
};
|
46
44
|
raw: (
|
@@ -46,11 +46,8 @@ type MiddlewareContext = {
|
|
46
46
|
set: (key: string, value: string) => void;
|
47
47
|
status: (code: number) => void;
|
48
48
|
cookies: {
|
49
|
-
|
50
|
-
set: (key: string, value: string) => void;
|
51
|
-
delete: () => void;
|
49
|
+
set: (key: string, value: string, options?: any) => void;
|
52
50
|
clear: () => void;
|
53
|
-
apply: () => void;
|
54
51
|
};
|
55
52
|
raw: (
|
56
53
|
body: string,
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: splitRouteChunks
|
3
|
+
---
|
4
|
+
|
5
|
+
# output.splitRouteChunks
|
6
|
+
|
7
|
+
- **Type:** `boolean`
|
8
|
+
- **Default:** `true`
|
9
|
+
|
10
|
+
When using convention-based routing, the framework will split js and css based on the route to load on demand. If your project does not want to split js and css based on routes, you can set this option to `false`.
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
```ts
|
15
|
+
export default {
|
16
|
+
output: {
|
17
|
+
splitRouteChunks: false,
|
18
|
+
},
|
19
|
+
}
|
20
|
+
```
|
@@ -75,4 +75,5 @@ Visit the page `http://localhost:8080/__polyfill__` on Chrome 51 to see:
|
|
75
75
|
:::caution
|
76
76
|
This feature only works when using Modern.js built-in Web Server.
|
77
77
|
|
78
|
+
If you need to customize the HTML template, please refer to [HTML Template](/guides/basic-features/html.html). Manually modifying the template through html.template / tools.html will cause this feature not work.
|
78
79
|
:::
|
@@ -9,7 +9,7 @@ sidebar_position: 1
|
|
9
9
|
|
10
10
|
Currently, Modern.js includes three solutions, each targeting at different development scenarios: web application development, npm package development, and document site development:
|
11
11
|
|
12
|
-

|
13
13
|
|
14
14
|
As a part of the Modern.js engineering system, each of these solutions can be used separately and has its own independent documentation site. Developers can choose one or more solutions as needed.
|
15
15
|
|
@@ -139,6 +139,8 @@ The bundle is generated to `dist/` by default, and the directory structure is as
|
|
139
139
|
└── js
|
140
140
|
```
|
141
141
|
|
142
|
+
> If you want to customize the output directory, please refer to [Output Files](https://modernjs.dev/builder/en/guide/basic/output-files.html).
|
143
|
+
|
142
144
|
## Verify
|
143
145
|
|
144
146
|
Execute `pnpm run serve` in the project to verify locally that the bundle is running correctly:
|
@@ -2,6 +2,7 @@
|
|
2
2
|
title: Plugin API
|
3
3
|
sidebar_position: 6
|
4
4
|
---
|
5
|
+
|
5
6
|
# Plugin API
|
6
7
|
|
7
8
|
The `setup` function of the plugin will receive an `api` imported parameter, and you can call some methods provided on the api to obtain information such as configuration and application context.
|
@@ -36,17 +37,40 @@ interface UserConfig {
|
|
36
37
|
source?: SourceConfig;
|
37
38
|
output?: OutputConfig;
|
38
39
|
server?: ServerConfig;
|
39
|
-
dev?: DevConfig;
|
40
40
|
deploy?: DeployConfig;
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
// ...other fields
|
42
|
+
}
|
43
|
+
```
|
44
|
+
|
45
|
+
Please refer to [Configuration](/configure/app/usage) for the specific meanings of configuration fields.
|
46
|
+
|
47
|
+
:::tip
|
48
|
+
This method returns a read-only configuration and cannot be modified. If you need to modify the configuration, please use [config hook](/guides/topic-detail/framework-plugin/hook-list.html#config).
|
49
|
+
:::
|
50
|
+
|
51
|
+
### useResolvedConfigContext
|
52
|
+
|
53
|
+
Used to retrieve the final configuration after parsing.
|
54
|
+
|
55
|
+
```ts
|
56
|
+
const useResolvedConfigContext: () => NormalizedConfig;
|
57
|
+
|
58
|
+
interface NormalizedConfig {
|
59
|
+
source: NormalizedSourceConfig;
|
60
|
+
output: NormalizedOutputConfig;
|
61
|
+
server: NormalizedServerConfig;
|
62
|
+
deploy: NormalizedDeployConfig;
|
63
|
+
_raw: UserConfig; // the original user config
|
64
|
+
// ...other fields
|
45
65
|
}
|
46
66
|
```
|
47
67
|
|
48
68
|
Please refer to [Configuration](/configure/app/usage) for the specific meanings of configuration fields.
|
49
69
|
|
70
|
+
:::tip
|
71
|
+
This method returns a read-only configuration and cannot be modified. If you need to modify the configuration, please use [config hook](/guides/topic-detail/framework-plugin/hook-list.html#config).
|
72
|
+
:::
|
73
|
+
|
50
74
|
### useAppContext
|
51
75
|
|
52
76
|
Used to retrieve the runtime context of the application.
|
@@ -75,29 +99,6 @@ interface IAppContext {
|
|
75
99
|
}
|
76
100
|
```
|
77
101
|
|
78
|
-
### useResolvedConfigContext
|
79
|
-
|
80
|
-
Used to retrieve the final configuration after parsing.
|
81
|
-
|
82
|
-
```ts
|
83
|
-
const useResolvedConfigContext: () => NormalizedConfig;
|
84
|
-
|
85
|
-
interface NormalizedConfig {
|
86
|
-
source: NormalizedSourceConfig;
|
87
|
-
output: OutputConfig;
|
88
|
-
server: ServerConfig;
|
89
|
-
dev: DevConfig;
|
90
|
-
deploy: DeployConfig;
|
91
|
-
tools: NormalizedToolsConfig;
|
92
|
-
plugins: PluginConfig;
|
93
|
-
runtime: RuntimeConfig;
|
94
|
-
runtimeByEntries?: RuntimeByEntriesConfig;
|
95
|
-
_raw: UserConfig;
|
96
|
-
}
|
97
|
-
```
|
98
|
-
|
99
|
-
Please refer to [Configuration](/configure/app/usage) for the specific meanings of configuration fields.
|
100
|
-
|
101
102
|
### useHookRunners
|
102
103
|
|
103
104
|
Used to retrieve the executor of Hooks and trigger the execution of specific Hooks.
|
@@ -12,8 +12,8 @@ API wrapper for file operations in microgenerators, providing methods to render
|
|
12
12
|
import { FsAPI } from '@modern-js/codesmith-api-fs';
|
13
13
|
|
14
14
|
export default async (context: GeneratorContext, generator: GeneratorCore) => {
|
15
|
-
const
|
16
|
-
await
|
15
|
+
const fsApi = new FsAPI(generator);
|
16
|
+
await fsApi.renderFile(
|
17
17
|
material.get('templates/a.js'),
|
18
18
|
target: 'b.js'
|
19
19
|
);
|
@@ -36,9 +36,7 @@ type HookContext = {
|
|
36
36
|
set: (key: string, value: string) => void;
|
37
37
|
status: (code: number) => void;
|
38
38
|
cookies: {
|
39
|
-
|
40
|
-
set: (key: string, value: string) => void;
|
41
|
-
delete: () => void;
|
39
|
+
set: (key: string, value: string, options?: any) => void;
|
42
40
|
clear: () => void;
|
43
41
|
};
|
44
42
|
raw: (
|
@@ -45,11 +45,8 @@ type MiddlewareContext = {
|
|
45
45
|
set: (key: string, value: string) => void;
|
46
46
|
status: (code: number) => void;
|
47
47
|
cookies: {
|
48
|
-
|
49
|
-
set: (key: string, value: string) => void;
|
50
|
-
delete: () => void;
|
48
|
+
set: (key: string, value: string, options?: any) => void;
|
51
49
|
clear: () => void;
|
52
|
-
apply: () => void;
|
53
50
|
};
|
54
51
|
raw: (
|
55
52
|
body: string,
|
package/docs/zh/blog/index.md
CHANGED
@@ -1,6 +1,74 @@
|
|
1
1
|
---
|
2
|
-
|
2
|
+
sidebar_position: 1
|
3
3
|
---
|
4
|
-
# Modern.js 2.0
|
5
4
|
|
6
|
-
|
5
|
+
# 博客
|
6
|
+
|
7
|
+
在这里,你可以了解到 Modern.js 的最新进展和技术分享。
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
## Modern.js v2 发布:支持 Rspack 构建
|
12
|
+
|
13
|
+
> 发表于 2023.03.16
|
14
|
+
|
15
|
+
大家好,很高兴地向大家宣布,Modern.js v2 版本已经正式发布了!
|
16
|
+
|
17
|
+
Modern.js 是字节跳动 Web Infra 团队开源的一套 Web 工程体系。在开源以来的一年多时间里,Modern.js 保持稳定的迭代节奏,数十位贡献者参与了开发,累计提交 2000+ 个 Pull Request,并支持了 Rspack 构建、嵌套路由、流式渲染等新特性。
|
18
|
+
|
19
|
+
在这篇文章里,我们会和大家一起聊一聊 Modern.js 在过去一年多时间里的变化。
|
20
|
+
|
21
|
+
[了解更多 →](/blog/updates/v2-release-note)
|
22
|
+
|
23
|
+
---
|
24
|
+
|
25
|
+
## React Streaming SSR 原理解析
|
26
|
+
|
27
|
+
> 发表于 2022.12.16
|
28
|
+
|
29
|
+
React 18 提供了一种新的 SSR 渲染模式: Streaming SSR。通过 Streaming SSR,我们可以实现以下两个功能:
|
30
|
+
|
31
|
+
- Streaming HTML:服务端可以分段传输 HTML 到浏览器,而不是像 React 18 以前一样,需要等待服务端渲染完成整个页面后才返回给浏览器。这样,浏览器可以更快的启动 HTML 的渲染,提高 FP、FCP 等性能指标。
|
32
|
+
- Selective Hydration:在浏览器端 hydration 阶段,可以只对已经完成渲染的区域做 hydration,而不需要等待整个页面渲染完成、所有组件的 JS bundle 加载完成,才能开始 hydration。这样可以更早的对已经完成渲染的区域做事件绑定,从而让页面获得更好的可交互性。
|
33
|
+
|
34
|
+
[了解更多 →](https://mp.weixin.qq.com/s/w4FS5sBcHqRl-Saqi19Y6g)
|
35
|
+
|
36
|
+
---
|
37
|
+
|
38
|
+
## React Server Component 介绍
|
39
|
+
|
40
|
+
> 发表于 2022.12.01
|
41
|
+
|
42
|
+
React 官方对 Server Component 是这样介绍的: **zero-bundle-size React Server Components**。
|
43
|
+
|
44
|
+
这是一种实验性探索,但相信该探索是个未来 React 发展的方向,与 React Server Component 相关的周边生态正在积极的建设当中。
|
45
|
+
|
46
|
+
[了解更多 →](https://mp.weixin.qq.com/s/B-XLvW00vl5RE1Ur3EW4ow)
|
47
|
+
|
48
|
+
---
|
49
|
+
|
50
|
+
## 2022 年 9 ~ 10 月更新内容
|
51
|
+
|
52
|
+
> 发表于 2022.11.01
|
53
|
+
|
54
|
+
Modern.js 9 ~ 10 月的最新版本为 v1.21.0,本双月的主要更新有:
|
55
|
+
|
56
|
+
- **支持 pnpm v7**:完成框架对 pnpm v7 的支持。
|
57
|
+
- **服务端增加 Typescript 作为 ts 文件编译器**。
|
58
|
+
|
59
|
+
[了解更多 →](/blog/updates/2022-0910-updates)
|
60
|
+
|
61
|
+
---
|
62
|
+
|
63
|
+
## 2022 年 7 ~ 8 月更新内容
|
64
|
+
|
65
|
+
> 发表于 2022.09.05
|
66
|
+
|
67
|
+
Modern.js 7 ~ 8 月的最新版本为 v1.17.0,本双月的主要更新有:
|
68
|
+
|
69
|
+
- **支持 React 18**:完成框架和插件对 React 18 的适配。
|
70
|
+
- **包版本统一**:Modern.js 所有组成包的版本号进行统一,提供升级命令。
|
71
|
+
- **模块工程支持 bundle 构建**:模块工程类型的项目,支持对产物做 bundle 构建。
|
72
|
+
- **Reduck v1.1**:发布 Reduck v1.1,使用文档全面更新。
|
73
|
+
|
74
|
+
[了解更多 →](/blog/updates/2022-0708-updates)
|
@@ -0,0 +1,96 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 99
|
3
|
+
---
|
4
|
+
|
5
|
+
# 2022 年 7 ~ 8 月更新内容
|
6
|
+
|
7
|
+
> 发表于 2022.09.05
|
8
|
+
|
9
|
+
Modern.js 7 ~ 8 月的最新版本为 v1.17.0,本双月的主要更新有:
|
10
|
+
|
11
|
+
- **支持 React 18**:完成框架和插件对 React 18 的适配。
|
12
|
+
- **包版本统一**:Modern.js 所有组成包的版本号进行统一,提供升级命令。
|
13
|
+
- **模块工程支持 bundle 构建**:模块工程类型的项目,支持对产物做 bundle 构建。
|
14
|
+
- **Reduck v1.1**:发布 Reduck v1.1,使用文档全面更新。
|
15
|
+
|
16
|
+
## 支持 React 18
|
17
|
+
|
18
|
+
Modern.js 框架和相关插件完成对 React 18 的适配。现在,只需要将项目中的 `react`、`react-dom` 两个包的版本,升级到最新的 React 18 大版本,就可以使用 React 18 的新功能。
|
19
|
+
|
20
|
+
注意,使用 `@modern-js/create` 命令默认创建的项目,安装的依赖 `react`、`react-dom` 的版本仍然为 17,如果希望使用 React 18,请手动升级这两个包的版本。
|
21
|
+
|
22
|
+
另外,SSR 流式渲染功能,目前尚在开发中,暂不支持。
|
23
|
+
|
24
|
+
## Modern.js 包版本统一
|
25
|
+
|
26
|
+
之前,组成 Modern.js 的各个包的版本号并不统一,Modern.js 自身的版本和这些包的版本缺少明确的对应关系。这不仅增加了我们的维护成本,而且给用户的使用和升级带来了很多困扰。
|
27
|
+
|
28
|
+
从 v1.15.0 版本开始,Modern.js 自身的版本号和所有组成包的版本号,进行了统一。例如,Modern.js v1.15.0,意味着所有组成包的版本号也是 v1.15.0。 每次发布新版本,Modern.js 所有包都会使用统一的版本号执行发布。 Github 上仓库的 [tag](https://github.com/modern-js-dev/modern.js/tags) 编号和 Modern.js 所有组成包的版本号是一一对应的。
|
29
|
+
|
30
|
+
我们提供了专门的升级工具: `@modern-js/upgrade`,可以自动升级 Modern.js 到当前的最新版本。使用方式为,在项目根路径下执行:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
npx @modern-js/upgrade
|
34
|
+
```
|
35
|
+
|
36
|
+
## 模块工程支持 bundle 构建
|
37
|
+
|
38
|
+
模块工程( `@modern-js/module-tools` )对底层实现进行重构,新增 [`output.buildConfig`](https://modernjs.dev/v1/docs/apis/module/config/output/build-config/) 配置,用于提供更加丰富的构建功能。
|
39
|
+
|
40
|
+
新的模块工程项目,不仅支持对产物做 bundless 构建,也支持 bundle 构建。通过配置 `buildConfig` 下的 [`buildType`](https://modernjs.dev/v1/docs/apis/module/config/output/build-config/build-type) ,即可进行 bundle 构建:
|
41
|
+
|
42
|
+
```ts
|
43
|
+
// modern.config.ts
|
44
|
+
import { defineConfig } from '@modern-js/module-tools';
|
45
|
+
|
46
|
+
export default defineConfig({
|
47
|
+
output: {
|
48
|
+
buildConfig: {
|
49
|
+
buildType: 'bundle', // 采用 bundle 构建
|
50
|
+
},
|
51
|
+
},
|
52
|
+
});
|
53
|
+
```
|
54
|
+
|
55
|
+
`buildConfig` 下还支持 [`bundleOptions`](https://modernjs.dev/v1/docs/apis/module/config/output/build-config/bundle-options) 配置,可以对构建行为做更多的自定义:如设置产物文件名、是否进行代码分片、设置代码压缩方式等。
|
56
|
+
|
57
|
+
## Reduck v1.1
|
58
|
+
|
59
|
+
Reduck 作为 Modern.js 的第一方状态管理方案,发布 v1.1 版本,增加对 React 18 Concurrent Rendering 的支持,并对开发体验和功能稳定性做了大量优化。
|
60
|
+
|
61
|
+
新增 API:
|
62
|
+
|
63
|
+
- [`useStore`](https://modernjs.dev/v1/docs/apis/app/runtime/model/use-store) :可以在组件内获取当前组件树共享的 Store,满足在组件外访问 Model 的场景需求。
|
64
|
+
- [`handleEffect`](https://modernjs.dev/v1/docs/apis/app/runtime/model/handle-effect):一个工具函数,可以极大地简化异步数据获取的逻辑代码。
|
65
|
+
- [`connect`](https://modernjs.dev/v1/docs/apis/app/runtime/model/connect): HOC 风格的 API,用于访问 Model。
|
66
|
+
|
67
|
+
开发体验方面,优化 Reduck 组成包的组织结构,减少用户侧依赖数量,现在只需要引入 `@modern-js-reduck/react` 一个包(Modern.js 中 Reduck 功能已内置,无需手动引入包);优化 API 的 TS 类型定义,改进类型信息的自动推导,整体达到 TS 支持开箱即用。
|
68
|
+
|
69
|
+
此外,对 Reduck [使用文档](https://modernjs.dev/v1/docs/guides/features/model/quick-start) 和 [API 文档](https://modernjs.dev/v1/docs/apis/app/runtime/model/model_) 做了全面更新,提供了更加丰富和详尽的内容。
|
70
|
+
|
71
|
+
## 其他更新
|
72
|
+
|
73
|
+
### 命令和配置
|
74
|
+
|
75
|
+
**新增命令**
|
76
|
+
|
77
|
+
- [`upgrade`](https://modernjs.dev/v1/docs/apis/app/commands/upgrade):自动升级 Modern.js 版本。功能同执行 `npx @modern-js/upgrade` 命令。
|
78
|
+
- [`inspect`](https://modernjs.dev/v1/docs/apis/app/commands/inspect):通过该命令可以输出当前项目使用的完整 webpack 配置。
|
79
|
+
- [`gen-release-note`](https://modernjs.dev/v1/docs/apis/module/commands/gen-release-note):自动根据当前仓库的 [changesets](https://github.com/changesets/changesets) 信息生成发布日志。此外,我们提供了[包版本管理专题文档](https://modernjs.dev/v1/docs/guides/features/changesets/introduce),方便大家更好的认识和使用 changesets 及相关功能。
|
80
|
+
|
81
|
+
**新增配置**
|
82
|
+
|
83
|
+
- [`source.preEntry`](https://modernjs.dev/v1/docs/apis/app/config/source/pre-entry):用于配置全局脚本,这段脚本会早于页面的代码执行。
|
84
|
+
|
85
|
+
### BFF
|
86
|
+
|
87
|
+
- 新增 [`afterLambdaRegisted`](https://modernjs.dev/v1/docs/apis/app/runtime/bff-server/after-lambda-registed) hook。用于使用 Express 框架时,在 BFF 函数注册路由之后执行。可以用来添加错误处理逻辑,新增路由等。
|
88
|
+
- 优化使用 Express 框架开发场景下的热更新性能。在比较大的项目中,BFF 函数更改,热更新也可以在几十毫秒内完成。
|
89
|
+
|
90
|
+
### SSR
|
91
|
+
|
92
|
+
- SSR 产物添加 Sourcemap,优化服务端调试 SSR 代码的体验。
|
93
|
+
|
94
|
+
### Web Server
|
95
|
+
|
96
|
+
- 支持按入口设置响应头,使用方式请参考[文档](https://modernjs.dev/v1/docs/apis/app/config/server/routes#自定义响应头)。
|
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 98
|
3
|
+
---
|
4
|
+
|
5
|
+
# 2022 年 9 ~ 10 月更新内容
|
6
|
+
|
7
|
+
> 发表于 2022.11.01
|
8
|
+
|
9
|
+
Modern.js 9 ~ 10 月的最新版本为 v1.21.0,本双月的主要更新有:
|
10
|
+
|
11
|
+
- **支持 pnpm v7**:完成框架对 pnpm v7 的支持。
|
12
|
+
- **服务端增加 Typescript 作为 ts 文件编译器**。
|
13
|
+
|
14
|
+
## 支持 pnpm v7
|
15
|
+
|
16
|
+
Modern.js 框架完成了对 pnpm v7 的变更适配。
|
17
|
+
|
18
|
+
使用 `npx @modern-js/create@modern-1` 创建项目时会根据用户当前环境的 pnpm 版本进行安装依赖操作,并且在初始化项目中会在 `.npmrc` 中添加
|
19
|
+
`strict-peer-dependencies=false` 配置,避免安装时由于 `peerDependencies` 缺失导致安装依赖失败问题。
|
20
|
+
同时适配 `release`、`deploy` 命令对 pnpm v7 的支持。
|
21
|
+
|
22
|
+
pnpm v7 在命令传参方面姿势发生了变化,需注意:
|
23
|
+
|
24
|
+
在使用 pnpm 调用 `package.json` 中的命令时,如果需要传递参数至 pnpm,需要将参数放到命令前。
|
25
|
+
|
26
|
+
例如使用 pnpm `--filter` 参数执行 prepare 命令:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
pnpm run --filter "./packages/**" prepare
|
30
|
+
```
|
31
|
+
|
32
|
+
如果需要传递参数至命令,需要将参数放到命令后。
|
33
|
+
|
34
|
+
例如,在如下 `package.json` 配置中:
|
35
|
+
|
36
|
+
```json
|
37
|
+
{
|
38
|
+
"scripts": {
|
39
|
+
"command": "modern command"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
执行 command 命令时携带参数方式为:
|
45
|
+
|
46
|
+
```bash
|
47
|
+
pnpm run command --options
|
48
|
+
```
|
49
|
+
|
50
|
+
## 服务端增加 Typescript 作为 ts 文件编译器
|
51
|
+
|
52
|
+
在 Modernjs 之前的版本中,我们为了保证前后端编译器的统一,使用了 Babel 作为前后端默认的编译器,并保持相同的编译逻辑,但随着使用的项目增多,我们发现在一些服务端常用的语法场景下,Babel 编译 ts 有一些问题。
|
53
|
+
|
54
|
+
因此,我们将服务端编译 ts 的编译器由 Babel 改为了 Typescript,在别名解析逻辑上与 Babel 版本保持一致,同样支持使用 `tsconfig.json` 或者插件设置别名。
|
55
|
+
|
56
|
+
在执行 build 命令时,已默认使用 Typescript 编译,并默认开启了类型校验,很多项目在 9、10 双月已经在使用。
|
57
|
+
|
58
|
+
执行 dev 命令时,如果希望使用 Typescript 编译,需要安装 `ts-node`,`tsconfig-paths` 到 `devDependencies`,否则默认仍然使用 Babel 编译。在 Modern.js 2.0 中,我们将使用 ts-node 作为默认的编译器。
|
59
|
+
|
60
|
+
## 其他更新
|
61
|
+
|
62
|
+
### 配置更新
|
63
|
+
|
64
|
+
- 支持在 `tools.webpackChain` 中获取 `HtmlWebpackPlugin` 对象,使用方式请参考[文档](https://modernjs.dev/v1/docs/apis/app/config/tools/webpack-chain#htmlwebpackplugin)。
|
65
|
+
|
66
|
+
### 底层依赖升级
|
67
|
+
|
68
|
+
- husky 升级至 v8
|
69
|
+
|
70
|
+
使用 `npx @modern-js/create@modern-1` 创建项目时,husky 会默认安装 v8 版本,并移除 `package.json` 中 husky 的配置,使用 `.husky` 文件夹的形式管理 husky 配置。
|
71
|
+
|
72
|
+
在初次安装依赖时需要执行 `npx husky install` 进行 husky 初始化,默认项目会在 prepare 命令中完成,如果 husky 配置未生效,可通过手动执行完成 husky 配置。
|
73
|
+
|
74
|
+
## 功能预告
|
75
|
+
|
76
|
+
Modern.js 团队目前除了正常开发维护 Modern 1.0 外,正在全力打造 Modern.js 2.0。
|
77
|
+
|
78
|
+
Modern.js 2.0 将带来新的构建体系,除了支持使用稳定的 webpack 进行构建,还即将支持将底层构建工具切换为自研的 Rust bundler,提供更流畅的编译速度。
|
79
|
+
|
80
|
+
Modern.js 2.0 将基于 [React-Router v6](https://reactrouter.com) 推荐嵌套路由作为新的路由方式;将默认支持 React 18 并提供 Streaming SSR 的支持,使用户体验更加流畅。
|