@modern-js/main-doc 2.65.5 → 2.66.0

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 (81) hide show
  1. package/docs/en/community/blog/v2-release-note.mdx +1 -1
  2. package/docs/en/configure/app/plugins.mdx +2 -2
  3. package/docs/en/configure/app/tools/esbuild.mdx +1 -1
  4. package/docs/en/configure/app/tools/swc.mdx +1 -1
  5. package/docs/en/plugin/_meta.json +8 -7
  6. package/docs/en/plugin/cli-plugins/_meta.json +1 -1
  7. package/docs/en/plugin/cli-plugins/api.mdx +617 -0
  8. package/docs/en/plugin/cli-plugins/life-cycle.mdx +139 -0
  9. package/docs/en/plugin/cli-plugins/migration.mdx +98 -0
  10. package/docs/en/plugin/introduction.mdx +119 -47
  11. package/docs/en/plugin/official/_meta.json +12 -0
  12. package/docs/en/plugin/official/cli-plugins/_meta.json +1 -0
  13. package/docs/en/plugin/official/cli-plugins.mdx +6 -0
  14. package/docs/en/plugin/official/rsbuild-plugins.mdx +3 -0
  15. package/docs/en/plugin/plugin-system.mdx +237 -0
  16. package/docs/en/plugin/runtime-plugins/_meta.json +1 -0
  17. package/docs/en/plugin/runtime-plugins/api.mdx +165 -0
  18. package/docs/en/plugin/runtime-plugins/life-cycle.mdx +29 -0
  19. package/docs/en/plugin/runtime-plugins/migration.mdx +101 -0
  20. package/docs/en/plugin/server-plugins/api.mdx +3 -0
  21. package/docs/en/plugin/server-plugins/life-cycle.mdx +3 -0
  22. package/docs/zh/community/blog/v2-release-note.mdx +1 -1
  23. package/docs/zh/configure/app/plugins.mdx +2 -2
  24. package/docs/zh/configure/app/tools/esbuild.mdx +1 -1
  25. package/docs/zh/configure/app/tools/swc.mdx +1 -1
  26. package/docs/zh/plugin/_meta.json +8 -7
  27. package/docs/zh/plugin/cli-plugins/_meta.json +1 -1
  28. package/docs/zh/plugin/cli-plugins/api.mdx +617 -0
  29. package/docs/zh/plugin/cli-plugins/life-cycle.mdx +139 -0
  30. package/docs/zh/plugin/cli-plugins/migration.mdx +98 -0
  31. package/docs/zh/plugin/introduction.mdx +92 -20
  32. package/docs/zh/plugin/official/_meta.json +12 -0
  33. package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -0
  34. package/docs/zh/plugin/official/cli-plugins.mdx +6 -0
  35. package/docs/zh/plugin/official/rsbuild-plugins.mdx +3 -0
  36. package/docs/zh/plugin/plugin-system.mdx +239 -0
  37. package/docs/zh/plugin/runtime-plugins/_meta.json +1 -0
  38. package/docs/zh/plugin/runtime-plugins/api.mdx +166 -0
  39. package/docs/zh/plugin/runtime-plugins/life-cycle.mdx +29 -0
  40. package/docs/zh/plugin/runtime-plugins/migration.mdx +101 -0
  41. package/docs/zh/plugin/server-plugins/api.mdx +3 -0
  42. package/docs/zh/plugin/server-plugins/life-cycle.mdx +3 -0
  43. package/i18n.json +4 -0
  44. package/package.json +3 -2
  45. package/src/components/Footer/index.tsx +1 -1
  46. package/src/components/Mermaid/index.tsx +60 -0
  47. package/src/components/Mermaid/style.scss +221 -0
  48. package/docs/en/plugin/cli-plugins.mdx +0 -6
  49. package/docs/en/plugin/plugin-system/_meta.json +0 -10
  50. package/docs/en/plugin/plugin-system/extend.mdx +0 -163
  51. package/docs/en/plugin/plugin-system/hook-list.mdx +0 -711
  52. package/docs/en/plugin/plugin-system/hook.mdx +0 -188
  53. package/docs/en/plugin/plugin-system/implement.mdx +0 -243
  54. package/docs/en/plugin/plugin-system/introduction.mdx +0 -95
  55. package/docs/en/plugin/plugin-system/lifecycle.mdx +0 -16
  56. package/docs/en/plugin/plugin-system/plugin-api.mdx +0 -138
  57. package/docs/en/plugin/plugin-system/relationship.mdx +0 -119
  58. package/docs/en/plugin/rsbuild-plugins.mdx +0 -3
  59. package/docs/zh/plugin/cli-plugins.mdx +0 -6
  60. package/docs/zh/plugin/plugin-system/_meta.json +0 -10
  61. package/docs/zh/plugin/plugin-system/extend.mdx +0 -163
  62. package/docs/zh/plugin/plugin-system/hook-list.mdx +0 -715
  63. package/docs/zh/plugin/plugin-system/hook.mdx +0 -173
  64. package/docs/zh/plugin/plugin-system/implement.mdx +0 -250
  65. package/docs/zh/plugin/plugin-system/introduction.mdx +0 -94
  66. package/docs/zh/plugin/plugin-system/lifecycle.mdx +0 -16
  67. package/docs/zh/plugin/plugin-system/plugin-api.mdx +0 -138
  68. package/docs/zh/plugin/plugin-system/relationship.mdx +0 -119
  69. package/docs/zh/plugin/rsbuild-plugins.mdx +0 -4
  70. /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-bff.mdx +0 -0
  71. /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-ssg.mdx +0 -0
  72. /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-swc.mdx +0 -0
  73. /package/docs/en/plugin/{cli-plugins → official/cli-plugins}/plugin-tailwind.mdx +0 -0
  74. /package/docs/en/plugin/{rsbuild-plugins → official/rsbuild-plugins}/_meta.json +0 -0
  75. /package/docs/en/plugin/{rsbuild-plugins → official/rsbuild-plugins}/plugin-esbuild.mdx +0 -0
  76. /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-bff.mdx +0 -0
  77. /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-ssg.mdx +0 -0
  78. /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-swc.mdx +0 -0
  79. /package/docs/zh/plugin/{cli-plugins → official/cli-plugins}/plugin-tailwind.mdx +0 -0
  80. /package/docs/zh/plugin/{rsbuild-plugins → official/rsbuild-plugins}/_meta.json +0 -0
  81. /package/docs/zh/plugin/{rsbuild-plugins → official/rsbuild-plugins}/plugin-esbuild.mdx +0 -0
@@ -0,0 +1,221 @@
1
+ .dark {
2
+ .modern-mermaid {
3
+ .flowchart-label {
4
+ rect {
5
+ fill: #23272f !important;
6
+ stroke: #81b1db !important;
7
+ stroke-width: 1px !important;
8
+ }
9
+
10
+ polygon {
11
+ fill: #23272f !important;
12
+ stroke: #81b1db !important;
13
+ stroke-width: 1px !important;
14
+ }
15
+
16
+ span.nodeLabel {
17
+ color: #ccc !important;
18
+ }
19
+ }
20
+
21
+ .edgeLabel {
22
+ fill: #23272f !important;
23
+ color: #ccc !important;
24
+ background-color: #23272f !important;
25
+ }
26
+
27
+ .flowchart-link {
28
+ stroke: #ccc !important;
29
+ }
30
+
31
+ .marker {
32
+ stroke: #ccc !important;
33
+ fill: #ccc !important;
34
+ }
35
+ }
36
+ }
37
+
38
+ .modern-doc {
39
+ .modern-mermaid {
40
+ svg {
41
+ display: block;
42
+ margin: 0 auto;
43
+ }
44
+ .flow-start,
45
+ .flow-end {
46
+ rect,
47
+ polygon {
48
+ fill: #666 !important;
49
+ stroke: #666 !important;
50
+ }
51
+
52
+ span.nodeLabel {
53
+ color: #fff !important;
54
+ }
55
+ }
56
+
57
+ .flow-optimization {
58
+ rect,
59
+ polygon {
60
+ fill: var(--tw-ring-color) !important;
61
+ stroke: var(--rp-container-details-link) !important;
62
+ }
63
+
64
+ span.nodeLabel {
65
+ color: #333 !important;
66
+ }
67
+ }
68
+
69
+ .flow-hook {
70
+ rect,
71
+ polygon {
72
+ fill: var(--rp-container-info-border) !important;
73
+ stroke: var(--rp-container-info-border) !important;
74
+ }
75
+
76
+ span.nodeLabel {
77
+ color: #333 !important;
78
+ }
79
+ }
80
+
81
+ .flow-hook-non-support {
82
+ rect,
83
+ polygon {
84
+ fill: var(--rp-container-danger-border) !important;
85
+ stroke: var(--rp-container-danger-border) !important;
86
+ }
87
+
88
+ span.nodeLabel {
89
+ color: #333 !important;
90
+ }
91
+ }
92
+
93
+ .flow-hook-partial-support {
94
+ rect,
95
+ polygon {
96
+ fill: var(--rp-container-warning-border) !important;
97
+ stroke: var(--rp-container-warning-border) !important;
98
+ }
99
+
100
+ span.nodeLabel {
101
+ color: #333 !important;
102
+ }
103
+ }
104
+
105
+ .flow-process {
106
+ rect,
107
+ polygon {
108
+ fill: var(--rp-container-details-border) !important;
109
+ stroke: var(--rp-container-details-border) !important;
110
+ }
111
+
112
+ span.nodeLabel {
113
+ color: #333 !important;
114
+ }
115
+ }
116
+ }
117
+
118
+ .flowchart-link {
119
+ stroke: #666 !important;
120
+ }
121
+
122
+ .marker {
123
+ stroke: #666 !important;
124
+ fill: #666 !important;
125
+ }
126
+
127
+ .cluster {
128
+ rect {
129
+ fill: transparent !important;
130
+ stroke: #666 !important;
131
+ }
132
+ }
133
+ }
134
+
135
+ .dark {
136
+ .rspress-doc {
137
+ .modern-mermaid {
138
+ .flow-start,
139
+ .flow-end {
140
+ rect,
141
+ polygon {
142
+ fill: #666 !important;
143
+ stroke: #666 !important;
144
+ }
145
+
146
+ span.nodeLabel {
147
+ color: #ccc !important;
148
+ }
149
+ }
150
+
151
+ .flow-optimization {
152
+ rect,
153
+ polygon {
154
+ fill: var(--tw-ring-color) !important;
155
+ stroke: var(--rp-container-details-link) !important;
156
+ }
157
+
158
+ span.nodeLabel {
159
+ color: #ccc !important;
160
+ }
161
+ }
162
+
163
+ .flow-hook {
164
+ rect,
165
+ polygon {
166
+ fill: var(--rp-container-info-bg) !important;
167
+ stroke: var(--rp-container-info-border) !important;
168
+ }
169
+
170
+ span.nodeLabel {
171
+ color: #ccc !important;
172
+ }
173
+ }
174
+
175
+ .flow-hook-non-support {
176
+ rect,
177
+ polygon {
178
+ fill: var(--rp-container-danger-bg) !important;
179
+ stroke: var(--rp-container-danger-border) !important;
180
+ }
181
+
182
+ span.nodeLabel {
183
+ color: #ccc !important;
184
+ }
185
+ }
186
+
187
+ .flow-hook-partial-support {
188
+ rect,
189
+ polygon {
190
+ fill: var(--rp-container-warning-bg) !important;
191
+ stroke: var(--rp-container-warning-border) !important;
192
+ }
193
+
194
+ span.nodeLabel {
195
+ color: #ccc !important;
196
+ }
197
+ }
198
+
199
+ .flow-process {
200
+ rect,
201
+ polygon {
202
+ fill: var(--rp-container-details-bg) !important;
203
+ stroke: var(--rp-container-details-border) !important;
204
+ }
205
+
206
+ span.nodeLabel {
207
+ color: #ccc !important;
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+
214
+ .modern-mermaid {
215
+ font-size: 20px;
216
+ text-align: center;
217
+ svg {
218
+ display: block;
219
+ margin: 0 auto;
220
+ }
221
+ }
@@ -1,6 +0,0 @@
1
- # Overview
2
-
3
- - [@modern-js/plugin-tailwindcss](/plugin/cli-plugins/plugin-tailwind): Enables the use of Tailwind CSS styles.
4
- - [@modern-js/plugin-bff](/plugin/cli-plugins/plugin-bff): Provides BFF services and unified invocation capabilities.
5
- - [@modern-js/plugin-ssg](/plugin/cli-plugins/plugin-ssg): Provides static site generation capabilities.
6
- - [@modern-js/plugin-swc](/plugin/cli-plugins/plugin-swc): Provides SWC compilation support.
@@ -1,10 +0,0 @@
1
- [
2
- "introduction",
3
- "lifecycle",
4
- "hook",
5
- "implement",
6
- "relationship",
7
- "extend",
8
- "plugin-api",
9
- "hook-list"
10
- ]
@@ -1,163 +0,0 @@
1
- ---
2
- sidebar_position: 5
3
- ---
4
-
5
- # Extending Plugin Hooks
6
-
7
- This section describes how to extend plugin Hooks by dynamically registering [Hook models](/plugin/plugin-system/hook).
8
-
9
- ## Example
10
-
11
- Here is a simple example to demonstrate how to extend plugin Hooks by adding Hooks that manage console output.
12
-
13
- First, we initialize an empty project file and add basic dependencies:
14
-
15
- ```bash
16
- $ npx @modern-js/create@latest modern-js-demo
17
- ```
18
-
19
- ### Creating Hooks
20
-
21
- First, let's create a Hook model:
22
-
23
- ```ts title=config/plugin/myPlugin.ts
24
- import { createWaterfall } from '@modern-js/plugin';
25
-
26
- const message = createWaterfall<string[]>();
27
- ```
28
-
29
- then register:
30
-
31
- ```ts title=config/plugin/myPlugin.ts
32
- import type { CliPlugin } from '@modern-js/core';
33
-
34
- export const myPlugin = (): CliPlugin => ({
35
- name: 'my-plugin',
36
-
37
- registerHook: {
38
- message,
39
- },
40
- });
41
- ```
42
-
43
- add Hook types:
44
-
45
- ```ts title=config/plugin/myPlugin.ts
46
- declare module '@modern-js/core' {
47
- export interface Hooks {
48
- message: typeof message;
49
- }
50
- }
51
- ```
52
-
53
- ### Using Hooks
54
-
55
- Create a plugin and add command handling logic through the `commands` Hook function:
56
-
57
- ```ts title=config/plugin/myPlugin.ts
58
- import type { CliPlugin } from '@modern-js/core';
59
-
60
- export const myPlugin = (): CliPlugin => ({
61
- name: 'my-plugin',
62
-
63
- setup(api) {
64
- return {
65
- commands({ program }) {
66
- program.command('message').action(async () => {
67
- const hookRunners = api.useHookRunners();
68
- const messages = hookRunners.message([]);
69
- console.log(messages.join('\n'));
70
- });
71
- },
72
- };
73
- },
74
- });
75
- ```
76
-
77
- now `config/plugin/myPlugin.ts` is:
78
-
79
- ```ts title=config/plugin/myPlugin.ts
80
- import { createWaterfall } from '@modern-js/plugin';
81
- import type { CliPlugin } from '@modern-js/core';
82
-
83
- const message = createWaterfall<string[]>();
84
-
85
- export const myPlugin = (): CliPlugin => ({
86
- name: 'my-plugin',
87
-
88
- registerHook: {
89
- message,
90
- },
91
-
92
- setup(api) {
93
- return {
94
- commands({ program }) {
95
- program.command('message').action(async () => {
96
- const hookRunners = api.useHookRunners();
97
- const messages = hookRunners.message([]);
98
- console.log(messages.join('\n'));
99
- });
100
- },
101
- };
102
- },
103
- });
104
-
105
- declare module '@modern-js/core' {
106
- export interface Hooks {
107
- message: typeof message;
108
- }
109
- }
110
- ```
111
-
112
- Then add this plugin in `modern.config.ts`:
113
-
114
- ```ts title="modern.config.ts"
115
- import { defineConfig } from '@modern-js/app-tools';
116
- import { myPlugin } from './config/plugin/myPlugin';
117
-
118
- export default defineConfig({
119
- plugins: [myPlugin()],
120
- });
121
- ```
122
-
123
- Now, run `npx modern message`, and the related logic will be executed, but no information is collected, so the console output is empty.
124
-
125
- add:
126
-
127
- ```ts title=config/plugin/otherPlugin.ts
128
- import type { CliPlugin } from '@modern-js/core';
129
-
130
- export const otherPlugin = (): CliPlugin => ({
131
- name: 'other-plugin',
132
-
133
- setup(api) {
134
- return {
135
- message(list) {
136
- return [...list, '[foo] line 0', '[foo] line 1'];
137
- },
138
- };
139
- },
140
- });
141
- ```
142
-
143
- add to config:
144
-
145
- ```ts title="modern.config.ts"
146
- import { defineConfig } from '@modern-js/app-tools';
147
- import { myPlugin } from './config/plugin/myPlugin';
148
- import { otherPlugin } from './config/plugin/otherPlugin';
149
-
150
- export default defineConfig({
151
- plugins: [myPlugin(), otherPlugin()],
152
- });
153
- ```
154
-
155
- run `npx modern message`, then we can get follow in console:
156
-
157
- ```bash
158
- $ modern message
159
- [foo] line 0
160
- [foo] line 1
161
- ```
162
-
163
- By using the above approach, you can extend plugin Hooks with various capabilities.