@modern-js/module-tools-docs 2.0.0-beta.4 → 2.0.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.
Files changed (198) hide show
  1. package/.eslintrc.js +13 -0
  2. package/docs/en/api/config/_category_.json +4 -0
  3. package/docs/en/api/{build-config.md → config/build-config.md} +198 -105
  4. package/docs/en/api/{build-preset.md → config/build-preset.md} +65 -46
  5. package/docs/{zh/api → en/api/config}/design-system.md +130 -127
  6. package/docs/en/api/config/plugins.md +18 -0
  7. package/docs/en/api/{test.md → config/testing.md} +21 -12
  8. package/docs/en/api/index.md +3 -1
  9. package/docs/en/api/plugin-api/_category_.json +4 -0
  10. package/docs/en/api/plugin-api/plugin-hooks.md +501 -0
  11. package/docs/en/guide/advance/_category_.json +4 -0
  12. package/docs/en/guide/advance/asset.mdx +47 -30
  13. package/docs/en/guide/advance/build-umd.mdx +88 -80
  14. package/docs/en/guide/advance/copy.md +31 -28
  15. package/docs/en/guide/advance/external-dependency.mdx +27 -23
  16. package/docs/en/guide/advance/in-depth-about-build.md +56 -50
  17. package/docs/en/guide/advance/in-depth-about-dev-command.md +7 -4
  18. package/docs/en/guide/advance/theme-config.mdx +80 -0
  19. package/docs/en/guide/basic/_category_.json +4 -0
  20. package/docs/en/guide/basic/before-getting-started.md +28 -23
  21. package/docs/en/guide/basic/command-preview.md +18 -14
  22. package/docs/en/guide/basic/modify-output-product.md +27 -20
  23. package/docs/en/guide/basic/publish-your-project.md +21 -19
  24. package/docs/en/guide/basic/test-your-project.mdx +19 -16
  25. package/docs/en/guide/basic/use-micro-generator.md +10 -7
  26. package/docs/en/guide/basic/using-storybook.mdx +27 -26
  27. package/docs/en/guide/best-practices/_category_.json +4 -0
  28. package/docs/en/guide/best-practices/components.mdx +783 -0
  29. package/docs/en/guide/intro/_category_.json +4 -0
  30. package/docs/en/guide/intro/getting-started.md +9 -4
  31. package/docs/en/guide/intro/welcome.md +4 -0
  32. package/docs/en/guide/intro/why-module-engineering-solution.md +5 -1
  33. package/docs/en/index.md +3 -5
  34. package/docs/en/plugins/guide/_category_.json +4 -0
  35. package/docs/en/plugins/guide/getting-started.mdx +84 -0
  36. package/docs/en/plugins/guide/plugin-object.mdx +85 -0
  37. package/docs/en/plugins/guide/setup-function.mdx +117 -0
  38. package/docs/en/plugins/official-list/_category_.json +4 -0
  39. package/docs/en/plugins/official-list/overview.md +6 -0
  40. package/docs/zh/api/config/_category_.json +4 -0
  41. package/docs/zh/api/config/build-config.md +658 -0
  42. package/docs/zh/api/{build-preset.md → config/build-preset.md} +49 -36
  43. package/docs/zh/api/config/design-system.md +1166 -0
  44. package/docs/zh/api/config/plugins.md +18 -0
  45. package/docs/zh/api/{testing.md → config/testing.md} +18 -13
  46. package/docs/zh/api/index.md +4 -1
  47. package/docs/zh/api/plugin-api/_category_.json +4 -0
  48. package/docs/zh/api/plugin-api/plugin-hooks.md +500 -0
  49. package/docs/zh/guide/advance/_category_.json +4 -0
  50. package/docs/zh/guide/advance/asset.mdx +47 -30
  51. package/docs/zh/guide/advance/build-umd.mdx +88 -71
  52. package/docs/zh/guide/advance/copy.md +31 -28
  53. package/docs/zh/guide/advance/external-dependency.mdx +27 -23
  54. package/docs/zh/guide/advance/in-depth-about-build.md +55 -50
  55. package/docs/zh/guide/advance/in-depth-about-dev-command.md +7 -4
  56. package/docs/zh/guide/advance/theme-config.mdx +78 -0
  57. package/docs/zh/guide/basic/_category_.json +4 -0
  58. package/docs/zh/guide/basic/before-getting-started.md +27 -22
  59. package/docs/zh/guide/basic/command-preview.md +17 -13
  60. package/docs/zh/guide/basic/modify-output-product.md +28 -21
  61. package/docs/zh/guide/basic/publish-your-project.md +22 -17
  62. package/docs/zh/guide/basic/test-your-project.mdx +20 -16
  63. package/docs/zh/guide/basic/use-micro-generator.md +10 -7
  64. package/docs/zh/guide/basic/using-storybook.mdx +27 -24
  65. package/docs/zh/guide/best-practices/_category_.json +4 -0
  66. package/docs/zh/guide/best-practices/components.mdx +793 -0
  67. package/docs/zh/guide/intro/_category_.json +4 -0
  68. package/docs/zh/guide/intro/getting-started.md +10 -4
  69. package/docs/zh/guide/intro/welcome.md +4 -0
  70. package/docs/zh/guide/intro/why-module-engineering-solution.md +5 -1
  71. package/docs/zh/index.md +3 -2
  72. package/docs/zh/plugins/guide/_category_.json +4 -0
  73. package/docs/zh/plugins/guide/getting-started.mdx +84 -0
  74. package/docs/zh/plugins/guide/plugin-object.mdx +85 -0
  75. package/docs/zh/plugins/guide/setup-function.mdx +117 -0
  76. package/docs/zh/plugins/official-list/_category_.json +4 -0
  77. package/docs/zh/plugins/official-list/overview.md +5 -0
  78. package/modern.config.ts +118 -0
  79. package/package.json +8 -6
  80. package/{docs/.island/styles → theme}/index.css +0 -1
  81. package/theme/index.ts +4 -0
  82. package/tsconfig.json +7 -0
  83. package/docs/.island/config.ts +0 -245
  84. package/docs/.island/dist/404.html +0 -41
  85. package/docs/.island/dist/assets/before-getting-started.1b82b538.js +0 -87
  86. package/docs/.island/dist/assets/before-getting-started.582a31cc.js +0 -87
  87. package/docs/.island/dist/assets/build-config.72eb0918.js +0 -804
  88. package/docs/.island/dist/assets/build-config.d8bb1658.js +0 -809
  89. package/docs/.island/dist/assets/build-preset.96805d7d.js +0 -256
  90. package/docs/.island/dist/assets/build-preset.c20dcd40.js +0 -256
  91. package/docs/.island/dist/assets/build-your-ui.7f349247.js +0 -2
  92. package/docs/.island/dist/assets/build-your-ui.a8361604.js +0 -2
  93. package/docs/.island/dist/assets/command-preview.2d45fc82.js +0 -264
  94. package/docs/.island/dist/assets/command-preview.dc51b953.js +0 -264
  95. package/docs/.island/dist/assets/components.esm.03560353.js +0 -9
  96. package/docs/.island/dist/assets/design-system.86694ff5.js +0 -1254
  97. package/docs/.island/dist/assets/design-system.c4745cce.js +0 -639
  98. package/docs/.island/dist/assets/dev.1d326a37.js +0 -37
  99. package/docs/.island/dist/assets/dev.1fd06000.js +0 -37
  100. package/docs/.island/dist/assets/down.f35427d3.svg +0 -1
  101. package/docs/.island/dist/assets/extension.12299fd6.js +0 -2
  102. package/docs/.island/dist/assets/extension.96dc63a4.js +0 -2
  103. package/docs/.island/dist/assets/getting-started.40e9218d.js +0 -117
  104. package/docs/.island/dist/assets/getting-started.b1ed3f10.js +0 -114
  105. package/docs/.island/dist/assets/github.3bf8ccee.svg +0 -1
  106. package/docs/.island/dist/assets/index.2b2347ea.js +0 -33
  107. package/docs/.island/dist/assets/index.6cef6f5f.js +0 -4
  108. package/docs/.island/dist/assets/index.cb118238.js +0 -36
  109. package/docs/.island/dist/assets/index.ccb6ce27.js +0 -4
  110. package/docs/.island/dist/assets/island_inject.11a12ecc.js +0 -1
  111. package/docs/.island/dist/assets/island_inject.b13deaee.js +0 -1
  112. package/docs/.island/dist/assets/loading.8c9bb911.svg +0 -1
  113. package/docs/.island/dist/assets/modify-output-product.7f6bff35.js +0 -100
  114. package/docs/.island/dist/assets/modify-output-product.b91eff1f.js +0 -100
  115. package/docs/.island/dist/assets/moon.6b705924.svg +0 -3
  116. package/docs/.island/dist/assets/plugin.895932d8.js +0 -42
  117. package/docs/.island/dist/assets/plugin.d2fbc531.js +0 -42
  118. package/docs/.island/dist/assets/publish-your-project.21b8309f.js +0 -164
  119. package/docs/.island/dist/assets/publish-your-project.8d398b17.js +0 -166
  120. package/docs/.island/dist/assets/right.89674cd7.svg +0 -1
  121. package/docs/.island/dist/assets/search.0aea6901.svg +0 -1
  122. package/docs/.island/dist/assets/search.1c85d17c.js +0 -3
  123. package/docs/.island/dist/assets/search.484eca11.js +0 -222
  124. package/docs/.island/dist/assets/search.54fca8d0.js +0 -3
  125. package/docs/.island/dist/assets/style.09015a4b.css +0 -1
  126. package/docs/.island/dist/assets/style.2e5f7bc2.css +0 -1970
  127. package/docs/.island/dist/assets/sun.841dac10.svg +0 -11
  128. package/docs/.island/dist/assets/test-your-project.18bd4582.js +0 -190
  129. package/docs/.island/dist/assets/test-your-project.f53bebf7.js +0 -190
  130. package/docs/.island/dist/assets/test.0da1f99f.js +0 -67
  131. package/docs/.island/dist/assets/test.0e81f002.js +0 -66
  132. package/docs/.island/dist/assets/translator.b1077c44.svg +0 -1
  133. package/docs/.island/dist/assets/use-micro-generator.7d9e4016.js +0 -60
  134. package/docs/.island/dist/assets/use-micro-generator.db5520c1.js +0 -60
  135. package/docs/.island/dist/assets/using-storybook.57ea6b77.js +0 -260
  136. package/docs/.island/dist/assets/using-storybook.a2212f2e.js +0 -260
  137. package/docs/.island/dist/assets/welcome.0449a9c8.js +0 -13
  138. package/docs/.island/dist/assets/welcome.a8448931.js +0 -13
  139. package/docs/.island/dist/assets/why-module-engineering-solution.6ae8c0e3.js +0 -26
  140. package/docs/.island/dist/assets/why-module-engineering-solution.c9a45cbd.js +0 -26
  141. package/docs/.island/dist/chunk-COLCRJ2V.js +0 -1
  142. package/docs/.island/dist/chunk-K5FMOYDC.js +0 -10
  143. package/docs/.island/dist/chunk-WE42KMYS.js +0 -26
  144. package/docs/.island/dist/client-entry.js +0 -3
  145. package/docs/.island/dist/en/api/build-config.html +0 -344
  146. package/docs/.island/dist/en/api/build-preset.html +0 -82
  147. package/docs/.island/dist/en/api/design-system.html +0 -155
  148. package/docs/.island/dist/en/api/dev.html +0 -45
  149. package/docs/.island/dist/en/api/index.html +0 -41
  150. package/docs/.island/dist/en/api/plugin.html +0 -48
  151. package/docs/.island/dist/en/api/test.html +0 -58
  152. package/docs/.island/dist/en/guide/before-getting-started.html +0 -127
  153. package/docs/.island/dist/en/guide/build-your-ui.html +0 -41
  154. package/docs/.island/dist/en/guide/command-preview.html +0 -100
  155. package/docs/.island/dist/en/guide/extension.html +0 -41
  156. package/docs/.island/dist/en/guide/getting-started.html +0 -76
  157. package/docs/.island/dist/en/guide/modify-output-product.html +0 -140
  158. package/docs/.island/dist/en/guide/publish-your-project.html +0 -91
  159. package/docs/.island/dist/en/guide/test-your-project.html +0 -72
  160. package/docs/.island/dist/en/guide/use-micro-generator.html +0 -65
  161. package/docs/.island/dist/en/guide/using-storybook.html +0 -113
  162. package/docs/.island/dist/en/guide/welcome.html +0 -53
  163. package/docs/.island/dist/en/guide/why-module-engineering-solution.html +0 -49
  164. package/docs/.island/dist/en/index.html +0 -42
  165. package/docs/.island/dist/react-dom.js +0 -1
  166. package/docs/.island/dist/react-dom_client.js +0 -1
  167. package/docs/.island/dist/react.js +0 -1
  168. package/docs/.island/dist/react_jsx-runtime.js +0 -10
  169. package/docs/.island/dist/ssr-manifest.json +0 -57
  170. package/docs/.island/dist/test-result.png +0 -0
  171. package/docs/.island/dist/why-module-solution.png +0 -0
  172. package/docs/.island/dist/zh/api/build-config.html +0 -347
  173. package/docs/.island/dist/zh/api/build-preset.html +0 -82
  174. package/docs/.island/dist/zh/api/design-system.html +0 -149
  175. package/docs/.island/dist/zh/api/dev.html +0 -46
  176. package/docs/.island/dist/zh/api/index.html +0 -41
  177. package/docs/.island/dist/zh/api/plugin.html +0 -48
  178. package/docs/.island/dist/zh/api/test.html +0 -59
  179. package/docs/.island/dist/zh/guide/before-getting-started.html +0 -127
  180. package/docs/.island/dist/zh/guide/build-your-ui.html +0 -41
  181. package/docs/.island/dist/zh/guide/command-preview.html +0 -100
  182. package/docs/.island/dist/zh/guide/extension.html +0 -41
  183. package/docs/.island/dist/zh/guide/getting-started.html +0 -79
  184. package/docs/.island/dist/zh/guide/modify-output-product.html +0 -140
  185. package/docs/.island/dist/zh/guide/publish-your-project.html +0 -92
  186. package/docs/.island/dist/zh/guide/test-your-project.html +0 -72
  187. package/docs/.island/dist/zh/guide/use-micro-generator.html +0 -65
  188. package/docs/.island/dist/zh/guide/using-storybook.html +0 -114
  189. package/docs/.island/dist/zh/guide/welcome.html +0 -53
  190. package/docs/.island/dist/zh/guide/why-module-engineering-solution.html +0 -49
  191. package/docs/.island/dist/zh/index.html +0 -42
  192. package/docs/.island/index.html +0 -39
  193. package/docs/en/api/design-system.md +0 -524
  194. package/docs/en/api/dev.md +0 -32
  195. package/docs/en/api/plugin.md +0 -34
  196. package/docs/zh/api/build-config.md +0 -570
  197. package/docs/zh/api/dev.md +0 -33
  198. package/docs/zh/api/plugins.md +0 -108
@@ -1,15 +1,19 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
1
5
  # BuildPreset
2
- 构建的预设字符串或者预设函数。提供开箱即用的构建配置
6
+
7
+ 构建的预设字符串或者预设函数。提供开箱即用的构建配置。
3
8
 
4
9
  - type: `string | Function`
5
10
  - default: `undefined`
6
11
 
7
-
8
12
  ## string
9
13
 
10
- 字符串的形式可以让你直接使用内置的预设
14
+ 字符串的形式可以让你直接使用内置的预设。
11
15
 
12
- ```ts modern.config.ts
16
+ ```js modern.config.ts
13
17
  import { defineConfig } from '@modern-js/module-tools';
14
18
 
15
19
  export default defineConfig({
@@ -17,42 +21,45 @@ export default defineConfig({
17
21
  });
18
22
  ```
19
23
 
20
-
21
24
  ### `'npm-library'`
25
+
22
26
  在类 [NPM](https://www.npmjs.com/) 包管理器下使用的 Library 通用模式,包含 `esm` 和 `cjs` 两种 Bundle 产物,并且包含一份类型文件。
23
27
 
24
28
  :::info
25
29
  关于类 [NPM](https://www.npmjs.com/) 包管理器
26
- * [npm](https://www.npmjs.com)
27
- * [yarn](https://yarnpkg.com/)
28
- * [pnpm](https://pnpm.io/)
29
- :::
30
30
 
31
- ```json title="package.json"
31
+ - [npm](https://www.npmjs.com)
32
+ - [yarn](https://yarnpkg.com/)
33
+ - [pnpm](https://pnpm.io/)
34
+ :::
35
+
36
+ ```json package.json
32
37
  {
33
- "main": "./dist/lib/index.js",
34
- "module": "./dist/es/index.js",
35
- "types": "./dist/types/index.d.ts",
38
+ "main": "./dist/lib/index.js",
39
+ "module": "./dist/es/index.js",
40
+ "types": "./dist/types/index.d.ts"
36
41
  }
37
42
  ```
43
+
38
44
  预设字符串对应的构建配置:
45
+
39
46
  ```js
40
47
  export const buildConfig = [
41
48
  {
42
49
  format: 'cjs',
43
50
  target: 'es6',
44
51
  buildType: 'bundle',
45
- outdir: './lib',
52
+ outDir: './lib',
46
53
  },
47
54
  {
48
55
  format: 'esm',
49
56
  target: 'es6',
50
57
  buildType: 'bundle',
51
- outdir: './es',
58
+ outDir: './es',
52
59
  },
53
60
  {
54
61
  buildType: 'bundle',
55
- outdir: './types',
62
+ outDir: './types',
56
63
  dts: {
57
64
  only: true,
58
65
  },
@@ -61,9 +68,10 @@ export const buildConfig = [
61
68
  ```
62
69
 
63
70
  ### `'npm-library-with-umd'`
71
+
64
72
  在类 [NPM](https://www.npmjs.com/) 包管理器下使用,并且 Library 支持类似 [unpkg](https://unpkg.com/) 的模式。在预设 `'npm-library'` 的基础上,额外提供 `umd` 产物。
65
73
 
66
- ```json title="package.json"
74
+ ```json package.json
67
75
  {
68
76
  "main": "./dist/lib/index.js",
69
77
  "module": "./dist/es/index.js",
@@ -71,30 +79,32 @@ export const buildConfig = [
71
79
  "unpkg": "./dist/umd/index.js",
72
80
  };
73
81
  ```
82
+
74
83
  预设字符串对应的构建配置:
84
+
75
85
  ```js
76
86
  export const buildConfig = [
77
87
  {
78
88
  format: 'cjs',
79
89
  target: 'es6',
80
90
  buildType: 'bundle',
81
- outdir: './lib',
91
+ outDir: './lib',
82
92
  },
83
93
  {
84
94
  format: 'esm',
85
95
  target: 'es6',
86
96
  buildType: 'bundle',
87
- outdir: './es',
97
+ outDir: './es',
88
98
  },
89
99
  {
90
100
  format: 'umd',
91
101
  target: 'es6',
92
102
  buildType: 'bundle',
93
- outdir: './umd',
103
+ outDir: './umd',
94
104
  },
95
105
  {
96
106
  buildType: 'bundle',
97
- outdir: './types',
107
+ outDir: './types',
98
108
  dts: {
99
109
  only: true,
100
110
  },
@@ -103,36 +113,38 @@ export const buildConfig = [
103
113
  ```
104
114
 
105
115
  ### `'npm-component'`
106
- 在类 [NPM](https://www.npmjs.com/) 包管理器下使用的 组件(库)通用模式。包含 `esm` 和 `cjs` 两种 Bundleless 产物(便于 *[Tree shaking](https://developer.mozilla.org/zh-CN/docs/Glossary/Tree_shaking)* 优化),以及包含一份类型文件。
116
+
117
+ 在类 [NPM](https://www.npmjs.com/) 包管理器下使用的 组件(库)通用模式。包含 `esm` 和 `cjs` 两种 Bundleless 产物(便于 _[Tree shaking](https://developer.mozilla.org/zh-CN/docs/Glossary/Tree_shaking)_ 优化),以及包含一份类型文件。
107
118
 
108
119
  对于源码中包含的样式文件,产物中提供样式的编译产物和样式的源文件。
109
120
 
110
- ```json title="package.json"
121
+ ```json package.json
111
122
  {
112
123
  "main": "./dist/lib/index.js", // bundleless type
113
124
  "module": "./dist/es/index.js", // bundleless type
114
125
  "types": "./dist/types/index.d.ts",
115
126
  };
116
127
  ```
128
+
117
129
  预设字符串对应的构建配置:
118
130
 
119
- ``` js
131
+ ```js
120
132
  export const buildConfig = [
121
133
  {
122
134
  format: 'cjs',
123
135
  target: 'es6',
124
136
  buildType: 'bundleless',
125
- outdir: './lib',
137
+ outDir: './lib',
126
138
  },
127
139
  {
128
140
  format: 'esm',
129
141
  target: 'es6',
130
142
  buildType: 'bundleless',
131
- outdir: './es',
143
+ outDir: './es',
132
144
  },
133
145
  {
134
146
  buildType: 'bundleless',
135
- outdir: './types',
147
+ outDir: './types',
136
148
  dts: {
137
149
  only: true,
138
150
  },
@@ -143,7 +155,8 @@ export const buildConfig = [
143
155
  ### `'npm-component-with-umd'`
144
156
 
145
157
  在类 [NPM](https://www.npmjs.com/) 包管理器下使用的组件(库),同时支持类 [unpkg](https://unpkg.com/) 的模式。 在预设 `'npm-component'` 的基础上,额外提供 `umd` 产物。
146
- ```json title="package.json"
158
+
159
+ ```json package.json
147
160
  {
148
161
  "main": "./dist/lib/index.js", // bundleless type
149
162
  "module": "./dist/es/index.js", // bundleless type
@@ -151,29 +164,30 @@ export const buildConfig = [
151
164
  "unpkg": "./dist/umd/index.js",
152
165
  };
153
166
  ```
167
+
154
168
  ```js
155
169
  export const buildConfig = [
156
170
  {
157
171
  format: 'cjs',
158
172
  target: 'es6',
159
173
  buildType: 'bundleless',
160
- outdir: './lib',
174
+ outDir: './lib',
161
175
  },
162
176
  {
163
177
  format: 'esm',
164
178
  target: 'es6',
165
179
  buildType: 'bundleless',
166
- outdir: './es',
180
+ outDir: './es',
167
181
  },
168
- {
182
+ {
169
183
  format: 'umd',
170
184
  target: 'es6',
171
185
  buildType: 'bundle',
172
- outdir: './umd',
186
+ outDir: './umd',
173
187
  },
174
188
  {
175
189
  buildType: 'bundleless',
176
- outdir: './types',
190
+ outDir: './types',
177
191
  dts: {
178
192
  only: true,
179
193
  },
@@ -183,12 +197,11 @@ export const buildConfig = [
183
197
 
184
198
  ### 关于预设值支持的 ECMAScript 版本以及 `{es5...esnext}`
185
199
 
186
-
187
200
  当想要使用支持其他 ECMAScript 版本的 `buildPreset` 预设的时候,可以直接在 `'npm-library'`、`'npm-library-with-umd'`、`'npm-component'`、`'npm-component-with-umd'` 这些预设值后面增加想要支持的版本。
188
201
 
189
202
  例如希望 `'npm-library'` 预设支持 `es2017`,则可以按照如下方式配置:
190
203
 
191
- ```ts modern.config.ts
204
+ ```js modern.config.ts
192
205
  import { defineConfig } from '@modern-js/module-tools';
193
206
 
194
207
  export default defineConfig({
@@ -201,7 +214,7 @@ export default defineConfig({
201
214
  函数的配置方式,可以通过 `preset` 参数获取到预设值,然后对里面的构建配置进行修改来自定义你的构建配置。
202
215
  以下是一个函数的配置方式的例子,它配置了压缩构建产物的功能:
203
216
 
204
- ```js
217
+ ```js modern.config.ts
205
218
  import { defineConfig } from '@modern-js/module-tools';
206
219
 
207
220
  export default defineConfig({