@modern-js/main-doc 2.16.0 → 2.17.1
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 +18 -0
- package/docs/en/community/blog/_category_.json +6 -0
- package/docs/en/{blog/index.md → community/blog/overview.md} +3 -1
- package/docs/en/guides/topic-detail/framework-plugin/hook-list.mdx +18 -12
- package/docs/en/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +2 -2
- package/docs/zh/community/blog/_category_.json +6 -0
- package/docs/zh/{blog/index.md → community/blog/overview.md} +6 -4
- package/docs/zh/guides/topic-detail/framework-plugin/hook-list.mdx +18 -12
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +2 -2
- package/modern.config.ts +9 -10
- package/package.json +5 -5
- package/docs/zh/blog/updates/_category_.json +0 -5
- /package/docs/en/{about → community}/contributing-guide.mdx +0 -0
- /package/docs/en/{about → community}/releases.mdx +0 -0
- /package/docs/en/{about → community}/showcase.mdx +0 -0
- /package/docs/en/{about → community}/team.mdx +0 -0
- /package/docs/zh/{blog/updates → community/blog}/2022-0708-updates.md +0 -0
- /package/docs/zh/{blog/updates → community/blog}/2022-0910-updates.md +0 -0
- /package/docs/zh/{blog/updates → community/blog}/v2-release-note.mdx +0 -0
- /package/docs/zh/{about → community}/contributing-guide.mdx +0 -0
- /package/docs/zh/{about → community}/releases.mdx +0 -0
- /package/docs/zh/{about → community}/showcase.mdx +0 -0
- /package/docs/zh/{about → community}/team.mdx +0 -0
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# @modern-js/main-doc
|
2
2
|
|
3
|
+
## 2.17.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- fc76194: chore: comment the doc for runtime and server plugin hooks
|
8
|
+
chore: 注释 runtime 和 server 插件钩子文档
|
9
|
+
- 7d899fb: fix: typo isFileExist
|
10
|
+
|
11
|
+
fix: isFileExist 拼写错误
|
12
|
+
|
13
|
+
- @modern-js/builder-doc@2.17.1
|
14
|
+
|
15
|
+
## 2.17.0
|
16
|
+
|
17
|
+
### Patch Changes
|
18
|
+
|
19
|
+
- @modern-js/builder-doc@2.17.0
|
20
|
+
|
3
21
|
## 2.16.0
|
4
22
|
|
5
23
|
### Patch Changes
|
@@ -611,7 +611,7 @@ export default (): CliPlugin => ({
|
|
611
611
|
|
612
612
|
This adds a new Script tag to the HTML template.
|
613
613
|
|
614
|
-
## Server
|
614
|
+
<!-- ## Server
|
615
615
|
|
616
616
|
:::note
|
617
617
|
The Server plugin is currently not fully opened, and the API is not guaranteed to be stable. Use with caution.
|
@@ -691,7 +691,7 @@ export default (): ServerPlugin => ({
|
|
691
691
|
};
|
692
692
|
},
|
693
693
|
});
|
694
|
-
```
|
694
|
+
``` -->
|
695
695
|
|
696
696
|
## Runtime
|
697
697
|
|
@@ -699,7 +699,7 @@ export default (): ServerPlugin => ({
|
|
699
699
|
The Runtime plugin is currently not fully opened, and the API is not guaranteed to be stable. Use with caution.
|
700
700
|
:::
|
701
701
|
|
702
|
-
The Runtime plugin is mainly used for developers to modify the
|
702
|
+
The Runtime plugin is mainly used for developers to modify the component that need to be rendered.
|
703
703
|
|
704
704
|
### `init`
|
705
705
|
|
@@ -732,23 +732,29 @@ export default (): Plugin => ({
|
|
732
732
|
- Type: `Pipeline<{ App: React.ComponentType<any>; }, React.ComponentType<any>>`
|
733
733
|
- Usage Example:
|
734
734
|
|
735
|
+
:::note
|
736
|
+
When using the hoc hook, you need to copy the static properties of the original App component to the new component and pass through the props.
|
737
|
+
:::
|
738
|
+
|
735
739
|
```ts
|
736
740
|
import { createContext } from 'react';
|
737
741
|
import type { Plugin } from '@modern-js/runtime';
|
742
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
738
743
|
|
739
744
|
export default (): Plugin => ({
|
740
745
|
setup(api) {
|
741
746
|
const FooContext = createContext('');
|
742
747
|
return {
|
743
748
|
hoc({ App }, next) {
|
749
|
+
const AppWrapper = (props: any) => {
|
750
|
+
return (
|
751
|
+
<FooContext.Provider store={'test'}>
|
752
|
+
<App {...props} />
|
753
|
+
</FooContext.Provider>
|
754
|
+
);
|
755
|
+
};
|
744
756
|
return next({
|
745
|
-
App: (
|
746
|
-
return (
|
747
|
-
<FooContext.Provider store={'test'}>
|
748
|
-
<App {...props} />
|
749
|
-
</FooContext.Provider>
|
750
|
-
);
|
751
|
-
},
|
757
|
+
App: hoistNonReactStatics(AppWrapper, App)
|
752
758
|
});
|
753
759
|
},
|
754
760
|
};
|
@@ -756,7 +762,7 @@ export default (): Plugin => ({
|
|
756
762
|
});
|
757
763
|
```
|
758
764
|
|
759
|
-
### `provide`
|
765
|
+
<!-- ### `provide`
|
760
766
|
|
761
767
|
- Function: Modifies the Elements that need to be rendered.
|
762
768
|
- Execution Stage: Rendering (SSR/CSR).
|
@@ -828,4 +834,4 @@ export default (): Plugin => ({
|
|
828
834
|
};
|
829
835
|
},
|
830
836
|
});
|
831
|
-
```
|
837
|
+
``` -->
|
@@ -2,7 +2,7 @@
|
|
2
2
|
sidebar_position: 2
|
3
3
|
---
|
4
4
|
|
5
|
-
#
|
5
|
+
# isFileExist
|
6
6
|
|
7
7
|
Determine if the file exists.
|
8
8
|
|
@@ -12,7 +12,7 @@ Its type is defined as:
|
|
12
12
|
|
13
13
|
```ts
|
14
14
|
export interface IPluginContext {
|
15
|
-
|
15
|
+
isFileExist: (fileName: string) => Promise<boolean>;
|
16
16
|
...
|
17
17
|
}
|
18
18
|
```
|
@@ -2,7 +2,9 @@
|
|
2
2
|
sidebar_position: 1
|
3
3
|
---
|
4
4
|
|
5
|
-
#
|
5
|
+
# 总览
|
6
|
+
|
7
|
+
欢迎来到 Modern.js 博客频道!
|
6
8
|
|
7
9
|
在这里,你可以了解到 Modern.js 的最新进展和技术分享。
|
8
10
|
|
@@ -18,7 +20,7 @@ Modern.js 是字节跳动 Web Infra 团队开源的一套 Web 工程体系。在
|
|
18
20
|
|
19
21
|
在这篇文章里,我们会和大家一起聊一聊 Modern.js 在过去一年多时间里的变化。
|
20
22
|
|
21
|
-
[了解更多 →](/blog/
|
23
|
+
[了解更多 →](/community/blog/v2-release-note)
|
22
24
|
|
23
25
|
---
|
24
26
|
|
@@ -56,7 +58,7 @@ Modern.js 9 ~ 10 月的最新版本为 v1.21.0,本双月的主要更新有:
|
|
56
58
|
- **支持 pnpm v7**:完成框架对 pnpm v7 的支持。
|
57
59
|
- **服务端增加 Typescript 作为 ts 文件编译器**。
|
58
60
|
|
59
|
-
[了解更多 →](/blog/
|
61
|
+
[了解更多 →](/community/blog/2022-0910-updates)
|
60
62
|
|
61
63
|
---
|
62
64
|
|
@@ -71,4 +73,4 @@ Modern.js 7 ~ 8 月的最新版本为 v1.17.0,本双月的主要更新有:
|
|
71
73
|
- **模块工程支持 bundle 构建**:模块工程类型的项目,支持对产物做 bundle 构建。
|
72
74
|
- **Reduck v1.1**:发布 Reduck v1.1,使用文档全面更新。
|
73
75
|
|
74
|
-
[了解更多 →](/blog/
|
76
|
+
[了解更多 →](/community/blog/2022-0708-updates)
|
@@ -611,7 +611,7 @@ export default (): CliPlugin => ({
|
|
611
611
|
|
612
612
|
这样就为 HTML 模版中新增了一个 Script 标签。
|
613
613
|
|
614
|
-
## Server
|
614
|
+
<!-- ## Server
|
615
615
|
|
616
616
|
:::note
|
617
617
|
目前 Server 插件还未完全开放,API 不保证稳定,使用需谨慎。
|
@@ -692,7 +692,7 @@ export default (): ServerPlugin => ({
|
|
692
692
|
};
|
693
693
|
},
|
694
694
|
});
|
695
|
-
```
|
695
|
+
``` -->
|
696
696
|
|
697
697
|
## Runtime
|
698
698
|
|
@@ -701,7 +701,7 @@ export default (): ServerPlugin => ({
|
|
701
701
|
|
702
702
|
:::
|
703
703
|
|
704
|
-
Runtime
|
704
|
+
Runtime 插件主要用于开发者修改需要渲染的组件。
|
705
705
|
|
706
706
|
### `init`
|
707
707
|
|
@@ -734,23 +734,29 @@ export default (): Plugin => ({
|
|
734
734
|
- 类型:`Pipeline<{ App: React.ComponentType<any>; }, React.ComponentType<any>>`
|
735
735
|
- 使用示例:
|
736
736
|
|
737
|
+
:::note
|
738
|
+
使用 hoc 钩子时,需要把原来的 App 组件的静态属性拷贝到新的组件上,并透传 props.
|
739
|
+
:::
|
740
|
+
|
737
741
|
```ts
|
738
742
|
import { createContext } from 'react';
|
739
743
|
import type { Plugin } from '@modern-js/runtime';
|
744
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
740
745
|
|
741
746
|
export default (): Plugin => ({
|
742
747
|
setup(api) {
|
743
748
|
const FooContext = createContext('');
|
744
749
|
return {
|
745
750
|
hoc({ App }, next) {
|
751
|
+
const AppWrapper = (props: any) => {
|
752
|
+
return (
|
753
|
+
<FooContext.Provider store={'test'}>
|
754
|
+
<App {...props} />
|
755
|
+
</FooContext.Provider>
|
756
|
+
);
|
757
|
+
};
|
746
758
|
return next({
|
747
|
-
App: (
|
748
|
-
return (
|
749
|
-
<FooContext.Provider store={'test'}>
|
750
|
-
<App {...props} />
|
751
|
-
</FooContext.Provider>
|
752
|
-
);
|
753
|
-
},
|
759
|
+
App: hoistNonReactStatics(AppWrapper, App)
|
754
760
|
});
|
755
761
|
},
|
756
762
|
};
|
@@ -758,7 +764,7 @@ export default (): Plugin => ({
|
|
758
764
|
});
|
759
765
|
```
|
760
766
|
|
761
|
-
### `provide`
|
767
|
+
<!-- ### `provide`
|
762
768
|
|
763
769
|
- 功能:修改需要渲染的 Element
|
764
770
|
- 执行阶段:渲染(SSR/CSR)
|
@@ -830,4 +836,4 @@ export default (): Plugin => ({
|
|
830
836
|
};
|
831
837
|
},
|
832
838
|
});
|
833
|
-
```
|
839
|
+
``` -->
|
@@ -2,7 +2,7 @@
|
|
2
2
|
sidebar_position: 2
|
3
3
|
---
|
4
4
|
|
5
|
-
#
|
5
|
+
# isFileExist
|
6
6
|
|
7
7
|
判断文件是否存在。
|
8
8
|
|
@@ -12,7 +12,7 @@ sidebar_position: 2
|
|
12
12
|
|
13
13
|
```ts
|
14
14
|
export interface IPluginContext {
|
15
|
-
|
15
|
+
isFileExist: (fileName: string) => Promise<boolean>;
|
16
16
|
...
|
17
17
|
}
|
18
18
|
```
|
package/modern.config.ts
CHANGED
@@ -7,8 +7,7 @@ const rootCategories = [
|
|
7
7
|
'guides',
|
8
8
|
'apis/app',
|
9
9
|
'configure/app',
|
10
|
-
'
|
11
|
-
'about',
|
10
|
+
'community',
|
12
11
|
];
|
13
12
|
|
14
13
|
const { version } = require('./package.json');
|
@@ -42,14 +41,9 @@ const getNavbar = (lang: string): NavItem[] => {
|
|
42
41
|
activeMatch: '/apis/',
|
43
42
|
},
|
44
43
|
{
|
45
|
-
text: getText('
|
46
|
-
link: getLink('/
|
47
|
-
activeMatch: '/
|
48
|
-
},
|
49
|
-
{
|
50
|
-
text: getText('关于', 'About'),
|
51
|
-
link: getLink('/about/showcase'),
|
52
|
-
activeMatch: '/about/',
|
44
|
+
text: getText('社区', 'Community'),
|
45
|
+
link: getLink('/community/showcase'),
|
46
|
+
activeMatch: '/community/',
|
53
47
|
},
|
54
48
|
{
|
55
49
|
text: `v${version}`,
|
@@ -122,6 +116,11 @@ export default defineConfig({
|
|
122
116
|
label: 'English',
|
123
117
|
},
|
124
118
|
],
|
119
|
+
editLink: {
|
120
|
+
docRepoBaseUrl:
|
121
|
+
'https://github.com/web-infra-dev/modern.js/tree/main/packages/document/main-doc/docs',
|
122
|
+
text: 'Edit this page on GitHub',
|
123
|
+
},
|
125
124
|
socialLinks: [
|
126
125
|
{
|
127
126
|
icon: 'github',
|
package/package.json
CHANGED
@@ -15,13 +15,13 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.17.1",
|
19
19
|
"publishConfig": {
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
21
21
|
"access": "public"
|
22
22
|
},
|
23
23
|
"peerDependencies": {
|
24
|
-
"@modern-js/builder-doc": "^2.
|
24
|
+
"@modern-js/builder-doc": "^2.17.1"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
27
|
"classnames": "^2",
|
@@ -33,9 +33,9 @@
|
|
33
33
|
"fs-extra": "^10",
|
34
34
|
"@types/node": "^16",
|
35
35
|
"@types/fs-extra": "^9",
|
36
|
-
"@modern-js/builder-doc": "2.
|
37
|
-
"@modern-js/doc-tools": "2.
|
38
|
-
"@modern-js/doc-plugin-auto-sidebar": "2.
|
36
|
+
"@modern-js/builder-doc": "2.17.1",
|
37
|
+
"@modern-js/doc-tools": "2.17.1",
|
38
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.17.1"
|
39
39
|
},
|
40
40
|
"scripts": {
|
41
41
|
"dev": "modern dev",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|