@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,10 +1,15 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+ # modify-output-product
5
+
1
6
  ## Modify output product
2
7
 
3
8
  ## Default output products
4
9
 
5
10
  When the `modern build` command is used in an initialized project, the products are generated according to the default configuration supported by Module Tools. The default supported configurations are as follows.
6
11
 
7
- ``` typescript
12
+ ```typescript
8
13
  import { defineConfig } from '@modern-js/module-tools';
9
14
 
10
15
  export default defineConfig({
@@ -20,8 +25,9 @@ export default defineConfig({
20
25
  - The output root directory is the `dist` directory under the project, and the output directory for type files is `dist/types`.
21
26
 
22
27
  :::tip
28
+
23
29
  1. By "code syntax support up to ES6", we mean that the syntax supported by the product code will not exceed `ES6`. If the source code uses syntax above `ES6` (e.g. `ES2017`), it will be converted.
24
- :::
30
+ :::
25
31
 
26
32
  You may have the following questions when you see this:
27
33
 
@@ -56,7 +62,7 @@ For example, if the output product is based on the preset string `"npm-library"`
56
62
 
57
63
  For example, if the same effect as the preset string `"npm-library-es2017"` is achieved using the preset function form, it can be done as follows:
58
64
 
59
- ``` typescript
65
+ ```typescript
60
66
  import { defineConfig } from "@modern-js/module-tools";
61
67
 
62
68
  export default defineConfig({
@@ -69,6 +75,7 @@ export default defineConfig({
69
75
  ```
70
76
 
71
77
  In the above code implementation, `preset.NPM_LIBRARY` corresponds to the preset string `"npm-library"`, which represents the `"npm-library"` equivalent of a multi-group build-related configuration. We traverse the `NPM_LIBRARY` array, which contains multiple `buildConfig` objects, with the `map` method. We make a shallow copy of the original `buildConfig` object and modify the shallow copy to get `buildConfig.target`, specifying it as `es2017`.
78
+
72
79
  > The specific value of `preset.NPM_LIBRARY` can be viewed via the [BuildPreset API](/en/api/build-config). The `preset` object contains not only `NPM_LIBRARY`, but also other similar constants.
73
80
 
74
81
  So what is the `buildConfig` object here? And what are the previously mentioned build product features based on?
@@ -77,7 +84,7 @@ We explain it next.
77
84
 
78
85
  ## Build configuration (object)
79
86
 
80
- **`buildConfig` is a configuration object that describes how to compile and generate build products**. What was mentioned at the beginning about "*features of build products*" are actually properties supported by `buildConfig`. The currently supported properties cover the needs of most module type projects when building products. `buildConfig` not only contains some of the properties that products have, but also some of the features needed to build products. The following is a brief list from a classification point of view:
87
+ **`buildConfig` is a configuration object that describes how to compile and generate build products**. What was mentioned at the beginning about "_features of build products_" are actually properties supported by `buildConfig`. The currently supported properties cover the needs of most module type projects when building products. `buildConfig` not only contains some of the properties that products have, but also some of the features needed to build products. The following is a brief list from a classification point of view:
81
88
 
82
89
  **The basic attributes of a build product include:**
83
90
 
@@ -87,7 +94,7 @@ We explain it next.
87
94
  - How to handle the output type file: the corresponding API is [`buildConfig.dts`](/en/api/build-config#dts).
88
95
  - How the sourceMap of the product is handled: the corresponding API is [`buildConfig.sourceMap`](/en/api/build-config#sourcemap).
89
96
  - The input (or source file) corresponding to the output: the corresponding API is [`buildConfig.input`](/en/api/build-config#input).
90
- - The directory of the output of the product: the corresponding API is [`buildConfig.outdir`](/en/api/build-config#outdir).
97
+ - The directory of the output of the product: the corresponding API is [`buildConfig.outDir`](/en/api/build-config#outDir).
91
98
  - The source directory of the build: the corresponding API is [`buildConfig.sourceDir`](/en/api/build-config#sourcedir).
92
99
 
93
100
  **Common functions needed to build products include:**
@@ -95,8 +102,8 @@ We explain it next.
95
102
  - Alias: The corresponding API is [`buildConfig.alias`](/en/api/build-config#alias).
96
103
  - Static resource handling: The corresponding API is [`buildConfig.asset`](/en/api/build-config#asset).
97
104
  - Third-party dependency handling: The corresponding APIs are
98
- * [`buildConfig.autoExternal`](/en/api/build-config#autoexternal).
99
- * [`buildConfig.externals`](/en/api/build-config#externals).
105
+ - [`buildConfig.autoExternal`](/en/api/build-config#autoexternal).
106
+ - [`buildConfig.externals`](/en/api/build-config#externals).
100
107
  - Copy: The corresponding API is [`buildConfig.copy`](/en/api/build-config#copy).
101
108
  - Global variable substitution: the corresponding API is [`buildConfig.define`](/en/api/build-config#define).
102
109
  - Specify [JSX](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html) compilation method, the corresponding API is [`buildConfig.jsx`](/en/api/build-config#jsx).
@@ -107,25 +114,25 @@ We explain it next.
107
114
  - Code splitting: [`buildConfig.splitting`](/en/api/build-config#splitting)
108
115
  - Specify whether the build product is for the NodeJS environment or the browser environment: the corresponding API is [`buildConfig.platform`](/en/api/build-config#platform).
109
116
  - umd product-related.
110
- * Specifies the global variables imported externally to the umd product: the corresponding API is [`buildConfig.umdGlobals`](/en/api/build-config#umdglobals).
111
- * Specify the module name of the umd product: the corresponding API is [`buildConfig.umdModuleName`](/en/api/build-config#umdmodulename).
117
+ - Specifies the global variables imported externally to the umd product: the corresponding API is [`buildConfig.umdGlobals`](/en/api/build-config#umdglobals).
118
+ - Specify the module name of the umd product: the corresponding API is [`buildConfig.umdModuleName`](/en/api/build-config#umdmodulename).
112
119
 
113
120
  In addition to the above categories, frequently asked questions and best practices about these APIs can be found at the following links.
114
121
 
115
- * [What are `bundle` and `bundleless`?](/en/guide/advance/in-depth-about-build#bundle-and-bundleless)
116
- * [The relationship between `input` and `sourceDir`](/en/guide/advance/in-depth-about-build#relationship-between-input-and-sourcedir)
117
- * [The multiple ways of generating type files in products](/en/guide/advance/in-depth-about-build#declaration-type-files)
118
- * [The use of `buildConfig.define` for different scenarios.](/en/guide/advance/in-depth-about-build#buildconfigdefine-usage-for-different-scenarios)
119
- * [How to handle third-party dependencies?](/en/guide/advance/external-dependency)
120
- * [How to use copy?](/en/guide/advance/copy)
121
- * [How to build umd products?](/en/guide/advance/build-umd)
122
- * [The capabilities currently supported by static resources.](/en/guide/advance/asset)
122
+ - [What are `bundle` and `bundleless`?](/en/guide/advance/in-depth-about-build#bundle-and-bundleless)
123
+ - [The relationship between `input` and `sourceDir`](/en/guide/advance/in-depth-about-build#relationship-between-input-and-sourcedir)
124
+ - [The multiple ways of generating type files in products](/en/guide/advance/in-depth-about-build#declaration-type-files)
125
+ - [The use of `buildConfig.define` for different scenarios.](/en/guide/advance/in-depth-about-build#buildconfigdefine-usage-for-different-scenarios)
126
+ - [How to handle third-party dependencies?](/en/guide/advance/external-dependency)
127
+ - [How to use copy?](/en/guide/advance/copy)
128
+ - [How to build umd products?](/en/guide/advance/build-umd)
129
+ - [The capabilities currently supported by static resources.](/en/guide/advance/asset)
123
130
 
124
131
  ## When to use `buildConfig`
125
132
 
126
133
  `buildConfig` is one of the ways used to modify the product, **and only `buildConfig` will take effect when configured in conjunction with `buildPreset`**. So if configured as follows.
127
134
 
128
- ``` typescript
135
+ ```typescript
129
136
  import { defineConfig } from '@modern-js/module-tools';
130
137
 
131
138
  export default defineConfig({
@@ -136,10 +143,10 @@ export default defineConfig({
136
143
 
137
144
  Then at this point you will see the following prompt.
138
145
 
139
- ``` bash
146
+ ```bash
140
147
  Since both 'buildConfig' and 'buildPreset' are present, only the 'buildConfig' configuration will take effect
141
148
  ```
142
149
 
143
150
  The set or sets of build-related configurations represented by `buildPreset` are composed of `buildConfig`, **which can be used to customize output products** when the current project needs cannot be met using `buildPreset`.
144
151
 
145
- The process of using `buildConfig` is the process of thinking about "*what kind of build product to get*".
152
+ The process of using `buildConfig` is the process of thinking about "_what kind of build product to get_".
@@ -1,26 +1,30 @@
1
+ ---
2
+ sidebar_position: 7
3
+ ---
4
+
1
5
  # Versioning and Publishing
2
6
 
3
7
  An npm-type module project release process consists of two phases.
4
8
 
5
- * The first phase is during development, where the developer needs to provide a change file to record changes that need to be released.
6
- * The second phase is during release, where Module Tools can collect all the change files to update the version, update the release log, and release new packages to the [npm Registry](https://www.npmjs.com/).
9
+ - The first phase is during development, where the developer needs to provide a change file to record changes that need to be released.
10
+ - The second phase is during release, where Module Tools can collect all the change files to update the version, update the release log, and release new packages to the [npm Registry](https://www.npmjs.com/).
7
11
 
8
12
  ## Tracking changes
9
13
 
10
14
  **Changes need to be logged when they happen to the project**. Changes that occur in a project are typically.
11
15
 
12
- * New features
13
- * Fixes to issues
14
- * Configuration file changes
15
- * ...
16
+ - New features
17
+ - Fixes to issues
18
+ - Configuration file changes
19
+ - ...
16
20
 
17
21
  Once these changes have been made, the current changes need to be documented with the following command.
18
22
 
19
- * [`modern change`](/zh/guide/command-preview#modern-change)
23
+ - [`modern change`](/zh/guide/command-preview#modern-change)
20
24
 
21
25
  Executing the `modern change` command asks the developer several questions and generates a change log based on the developer's answers. The changelog file contains the type of change and its description, and is committed to the git repository.
22
26
 
23
- ``` bash
27
+ ```bash
24
28
  $ npx modern change
25
29
  🦋 What kind of change is this for module-example? (current version is 0.1.0) - patch
26
30
  🦋 Please enter a summary for this change (this will be in the changelogs). Submit empty line to open external editor
@@ -37,7 +41,7 @@ $ npx modern change
37
41
 
38
42
  When executed successfully, the resulting Markdown file containing the change log is saved in the project's `.changeset` directory. The contents will look like the following.
39
43
 
40
- ``` markdown .changeset/brave-dryers-agree.md
44
+ ```markdown .changeset/brave-dryers-agree.md
41
45
  ---
42
46
  "``module-example'': patch
43
47
  ---
@@ -49,14 +53,15 @@ publish test
49
53
 
50
54
  When the project version needs to be updated, execute the following command.
51
55
 
52
- * [`modern bump`](/zh/guide/command-preview#modern-bump)
56
+ - [`modern bump`](/zh/guide/command-preview#modern-bump)
53
57
 
54
58
  Executing `modern bump` will modify the version number in `package.json` based on the contents of the Markdown file in the `.changeset/` directory where the changes were recorded, and generate the `CHANGELOG.md` file. **These Markdown files are also deleted when the version update is complete, so they are "consumed "**.
55
59
 
56
- ``` markdown CHANGELOG.md
60
+ ```markdown CHANGELOG.md
57
61
  # module
58
62
 
59
63
  ## 0.1.1
64
+
60
65
  ### Patch Changes
61
66
 
62
67
  - publish test
@@ -66,13 +71,13 @@ Executing `modern bump` will modify the version number in `package.json` based o
66
71
 
67
72
  To publish a project, you can execute the following command.
68
73
 
69
- * [`modern publish`](/zh/guide/command-preview#modern-release)
74
+ - [`modern publish`](/zh/guide/command-preview#modern-release)
70
75
 
71
76
  The `modern release` command publishes the project to the npm Registry.
72
77
 
73
78
  The release is the `latest` version, which is also the official version. If you want to change the `dist-tag`, you can specify it with the `modern release --tag` command. For example.
74
79
 
75
- ``` bash
80
+ ```bash
76
81
  modern release --tag beta
77
82
  ```
78
83
 
@@ -84,11 +89,11 @@ However, if you want to change the version number of the current project to a pr
84
89
 
85
90
  When a pre-release is needed before the official release, the following command is executed.
86
91
 
87
- * [`modern pre`](/zh/guide/command-preview#modern-pre)
92
+ - [`modern pre`](/zh/guide/command-preview#modern-pre)
88
93
 
89
94
  First `modern pre enter <tag>` to enter pre-release mode, `<tag>` can be the same as the `tag` specified with the `modern release --tag` command when releasing the project.
90
95
 
91
- ``` bash
96
+ ````bash
92
97
  $ npx modern pre enter next
93
98
  🦋 success Entered pre mode with tag next
94
99
  🦋 info Run `changeset version` to version packages with prerelease versions
@@ -105,11 +110,8 @@ $ npx modern bump
105
110
  🦋 warn You can then run `changeset version` again to do a normal release
106
111
  🦋 warn ----------------------------------------------------------------------
107
112
  🦋 All files have been updated. review them and commit at your leisure
108
- ```
113
+ ````
109
114
 
110
115
  Then you can see that the updated version number in `package.json` will look like this: `0.1.2-next.0`.
111
116
 
112
117
  Finally, **if you don't need to do a pre-release anymore, be sure to run the `modern pre exit` command** to exit the pre-release state and to release the official version when you run the `modern bump` command again.
113
-
114
-
115
- Translated with www.DeepL.com/Translator (free version)
@@ -1,3 +1,7 @@
1
+ ---
2
+ sidebar_position: 6
3
+ ---
4
+
1
5
  # Testing Projects
2
6
 
3
7
  This chapter will describe how to test modules.
@@ -6,20 +10,19 @@ This chapter will describe how to test modules.
6
10
 
7
11
  To use the testing functionality of the project, you need to make sure that the project contains the following dependencies:
8
12
 
9
- * `"@modern-js/plugin-testing"`
13
+ - `"@modern-js/plugin-testing"`
10
14
 
11
15
  In the module engineering scheme, the following conventions are in place for test cases, or files for writing tests:
12
16
 
13
- * The `tests` directory in the project directory is the directory for test cases and test files, **no support for changing the directory for running test cases**.
14
- * Files with the suffix `.test.[tj]sx?` are automatically recognized as test files by default.
15
- * Other `. [tj]sx?` suffixes are recognized as normal files that can be used as test `utils` files or for other purposes.
16
-
17
+ - The `tests` directory in the project directory is the directory for test cases and test files, **no support for changing the directory for running test cases**.
18
+ - Files with the suffix `.test.[tj]sx?` are automatically recognized as test files by default.
19
+ - Other `. [tj]sx?` suffixes are recognized as normal files that can be used as test `utils` files or for other purposes.
17
20
 
18
21
  ## Run the tests
19
22
 
20
23
  Once the dependencies are prepared and we know where to write the test cases, we can execute the tests with the following command:
21
24
 
22
- ``` bash
25
+ ```bash
23
26
  modern test
24
27
 
25
28
  // Update snapshot
@@ -28,13 +31,13 @@ modern test --updateSnapshot
28
31
 
29
32
  After execution, you will see the results of the test:
30
33
 
31
- ![test-result](/test-result.png)
34
+ ![test-result](https://lf3-static.bytednsdoc.com/obj/eden-cn/uhbfnupenuhf/test-result.png)
32
35
 
33
36
  ## Usage Configuration
34
37
 
35
38
  The Module Engineering Program provides the following configurations for testing.
36
39
 
37
- * [`testing`](/zh/api/config-test)
40
+ - [`testing`](/zh/api/config-test)
38
41
 
39
42
  You can add it in `modern.config.(j|t)s`.
40
43
 
@@ -46,7 +49,7 @@ For common modules, we can use the test function as follows:
46
49
 
47
50
  <CH.Spotlight>
48
51
 
49
- ``` typescript ./src/index.ts
52
+ ```typescript ./src/index.ts
50
53
  export default function () {
51
54
  return 'hello world';
52
55
  }
@@ -56,7 +59,7 @@ export default function () {
56
59
 
57
60
  First is the code of the module.
58
61
 
59
- ``` typescript ./src/index.ts
62
+ ```typescript ./src/index.ts
60
63
  export default function () {
61
64
  return 'hello world';
62
65
  }
@@ -68,7 +71,7 @@ Then in the test file, we can do this.
68
71
 
69
72
  Where `@` points to the source directory, defined in `tests/tsconfig.json` in the initialization project.
70
73
 
71
- ``` typescript ./tests/index.test.ts
74
+ ```typescript ./tests/index.test.ts
72
75
  import main from '@/index';
73
76
 
74
77
  describe('default cases', () => {
@@ -84,7 +87,7 @@ describe('default cases', () => {
84
87
 
85
88
  Finally we can execute `modern test`.
86
89
 
87
- ``` bash
90
+ ```bash
88
91
  pnpm test
89
92
  ## or
90
93
  yarn test
@@ -104,7 +107,7 @@ If you need to use the Runtime API, then you can turn it on via [microgenerator]
104
107
 
105
108
  <CH.Spotlight>
106
109
 
107
- ``` tsx ./src/index.tsx
110
+ ```tsx ./src/index.tsx
108
111
  export const default () {
109
112
  return (
110
113
  <div>This is a UI Component</div>
@@ -116,7 +119,7 @@ export const default () {
116
119
 
117
120
  First is the code of the component.
118
121
 
119
- ``` tsx ./src/index.tsx
122
+ ```tsx ./src/index.tsx
120
123
  export const default () {
121
124
  return (
122
125
  <div>This is a UI Component</div>
@@ -130,7 +133,7 @@ Then in the test file, we can do this.
130
133
 
131
134
  Where `@` points to the source directory, defined in `tests/tsconfig.json` in the initialization project.
132
135
 
133
- ``` tsx ./tests/index.test.tsx
136
+ ```tsx ./tests/index.test.tsx
134
137
  import { render, screen } from '@modern-js/runtime/testing';
135
138
 
136
139
  import Component from '@/index';
@@ -147,7 +150,7 @@ describe('default cases', () => {
147
150
 
148
151
  Finally we can execute `modern test`.
149
152
 
150
- ``` bash
153
+ ```bash
151
154
  pnpm test
152
155
  ## or
153
156
  yarn test
@@ -1,10 +1,14 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
1
5
  # Using the Microgenerator
2
6
 
3
7
  The Module Engineering solution provides the Microgenerator tool, which allows for the current project to.
4
8
 
5
- * add new directories and files
6
- * Modify the contents of the `package.json` file
7
- * Execute commands
9
+ - add new directories and files
10
+ - Modify the contents of the `package.json` file
11
+ - Execute commands
8
12
 
9
13
  Thus with these capabilities, **Microgenerator can enable additional feature functionality for the project**.
10
14
 
@@ -16,8 +20,8 @@ The **Storybook feature** can be enabled when we want to debug a component or a
16
20
 
17
21
  For more information on how to start Storybook and how to use it, check out the following link.
18
22
 
19
- * [`modern dev`](/en/guide/command-preview#modern-dev)
20
- * [using Storybook](xxx)
23
+ - [`modern dev`](/en/guide/command-preview#modern-dev)
24
+ - [using Storybook](xxx)
21
25
 
22
26
  ## Tailwind CSS support
23
27
 
@@ -25,8 +29,7 @@ This can be enabled when we want to add [Tailwind CSS](https://v2.tailwindcss.co
25
29
 
26
30
  For more information on how to use Tailwind CSS in your module projects, check out.
27
31
 
28
- * [Using Tailwind CSS](xxx)
29
-
32
+ - [Using Tailwind CSS](xxx)
30
33
 
31
34
  ## Modern.js Runtime API
32
35
 
@@ -1,17 +1,21 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
1
5
  # Using Storybook
2
6
 
3
7
  First of all, if you haven't read the following, take a few minutes to understand it first.
4
8
 
5
- * [use micro-generator to enable Storybook debugging](/en/guide/use-micro-generator#storybook-debug)
6
- * [`modern dev`](/en/guide/command-preview#modern-dev)
9
+ - [use micro-generator to enable Storybook debugging](/en/guide/use-micro-generator#storybook-debug)
10
+ - [`modern dev`](/en/guide/command-preview#modern-dev)
7
11
 
8
12
  [Storybook](https://storybook.js.org/) is a tool dedicated to component debugging, providing around component development.
9
13
 
10
- * Develop UIs that are more durable
11
- * Test UIs with less effort and no flakes
12
- * Document UI for your team to reuse
13
- * Share how the UI actually works
14
- * Automate UI workflows
14
+ - Develop UIs that are more durable
15
+ - Test UIs with less effort and no flakes
16
+ - Document UI for your team to reuse
17
+ - Share how the UI actually works
18
+ - Automate UI workflows
15
19
 
16
20
  So it is a complex and powerful tool.
17
21
 
@@ -21,8 +25,8 @@ The modular engineering solution is integrated with Storybook, so you can pretty
21
25
 
22
26
  Component code needs to be introduced during debugging code, and currently component code can be introduced in two ways:
23
27
 
24
- * Referencing the component product
25
- * Referencing component source code
28
+ - Referencing the component product
29
+ - Referencing component source code
26
30
 
27
31
  We recommend the first way of "**referencing component product**". Because it is almost close to the real usage scenario, not only can we debug the component functionality, but also verify the correctness of the build product.
28
32
 
@@ -36,9 +40,9 @@ If the TypeScript project `foo` exists.
36
40
 
37
41
  ```json package.json
38
42
  {
39
- "name": "foo",
40
- "main": "./dist/index.js",
41
- "types": "./dist/types/index.d.ts"
43
+ "name": "foo",
44
+ "main": "./dist/index.js",
45
+ "types": "./dist/types/index.d.ts"
42
46
  }
43
47
  ```
44
48
 
@@ -49,9 +53,9 @@ values are real paths.
49
53
 
50
54
  ```json package.json
51
55
  {
52
- "name": "foo",
53
- "main": "./dist/index.js",
54
- "types": "./dist/types/index.d.ts"
56
+ "name": "foo",
57
+ "main": "./dist/index.js",
58
+ "types": "./dist/types/index.d.ts"
55
59
  }
56
60
  ```
57
61
 
@@ -65,7 +69,6 @@ export const content = 'hello world';
65
69
 
66
70
  ---
67
71
 
68
-
69
72
  Make sure that the `paths` configuration pointing to the project root is set in `stories/tsconfig.json`.
70
73
  The `key` of `paths` is the same as the project name.
71
74
 
@@ -105,7 +108,7 @@ If, during development, you encounter a situation where the type definition is n
105
108
 
106
109
  For `pnpm` projects, `package.json` can be modified as follows.
107
110
 
108
- ``` ts focus=4:7
111
+ ```ts focus=4:7
109
112
  {
110
113
  "name": "foo",
111
114
  "main": "./dist/index.js",
@@ -115,17 +118,16 @@ For `pnpm` projects, `package.json` can be modified as follows.
115
118
  }
116
119
  }
117
120
  ```
121
+
118
122
  > For the use of pnpm's `publishConfig`, you can read the following [link](https://pnpm.io/package_json#publishconfig).
119
123
 
120
124
  For npm and Yarn projects, the values of `types` of `package.json` can only be changed manually in **development phase** and **release phase**.
121
125
 
122
-
123
126
  So why is it possible to reference the product directly?
124
127
 
125
128
  1. the `modern build` command is executed automatically before the `modern dev storybook` command, ensuring the existence of the project build product.
126
129
  2. The project name is added as an alias inside Storybook to ensure that the path to the project's product can be parsed **according to `package.json`**.
127
130
 
128
-
129
131
  ### Referencing component source code
130
132
 
131
133
  Referencing component source code can be done by means of relative paths to:
@@ -146,7 +148,6 @@ So why is the source code approach not recommended?
146
148
 
147
149
  Not only is it impossible to verify that the component product is correct using the component source code, **but also some of the configurations supported by the module project for building the product cannot be fully translated into Storybook internal configuration**. If some of the configurations cannot be converted to each other, there will be unintended results during Storybook debugging.
148
150
 
149
-
150
151
  ## Configure Storybook
151
152
 
152
153
  ### Configuration file
@@ -155,12 +156,12 @@ Storybook is officially configured for projects through a folder called `.storyb
155
156
 
156
157
  For more information on how to use the various Storybook configuration files, see the following links:
157
158
 
158
- * [Configure Storybook](https://storybook.js.org/docs/react/configure/overview)
159
+ - [Configure Storybook](https://storybook.js.org/docs/react/configure/overview)
159
160
 
160
161
  **But there are some limitations to Storybooking in a module project**:
161
162
 
162
- * It is currently not possible to change the location of the Story file, i.e., you cannot change the `stories` configuration in the `main.js` file.
163
- * Currently you cannot modify Webpack and Babel related configuration, i.e. you cannot modify `webpackFinal` and `babel` configuration in the `main.js` file.
163
+ - It is currently not possible to change the location of the Story file, i.e., you cannot change the `stories` configuration in the `main.js` file.
164
+ - Currently you cannot modify Webpack and Babel related configuration, i.e. you cannot modify `webpackFinal` and `babel` configuration in the `main.js` file.
164
165
 
165
166
  In the future we will consider whether these configurations can be allowed to be modified, but for now we are limiting their use to reduce unpredictable issues.
166
167
 
@@ -170,18 +171,18 @@ In addition to the configuration file, the module engineering solution also prov
170
171
 
171
172
  The webpack configuration of Storybook can be modified via this configuration.
172
173
 
173
- * [`dev.storybook.webpack`](xxx)
174
+ - [`dev.storybook.webpack`](xxx)
174
175
 
175
176
  ### Building Storybook Products
176
177
 
177
178
  In addition to Storybook debugging of components or common modules, you can also perform Storybook build tasks with the following commands.
178
179
 
179
- ``` bash
180
+ ```bash
180
181
  modern build --platform storybook
181
182
  ```
182
183
 
183
184
  For the `modern build --platform` command you can see.
184
185
 
185
- * [`modern build`](/en/guide/command-preview#modern-build)
186
+ - [`modern build`](/en/guide/command-preview#modern-build)
186
187
 
187
188
  After the build is complete, you can see the build product files in the `dist/storybook-static` directory.
@@ -0,0 +1,4 @@
1
+ {
2
+ "label": "Best practices",
3
+ "sidebar_position": 4
4
+ }