@modern-js/module-tools-docs 2.29.0 → 2.31.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 (53) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/docs/en/api/config/build-config.mdx +80 -53
  3. package/docs/en/api/config/build-preset.mdx +15 -33
  4. package/docs/en/api/config/design-system.md +42 -34
  5. package/docs/en/api/config/plugins.md +3 -3
  6. package/docs/en/api/config/testing.md +2 -2
  7. package/docs/en/api/plugin-api/plugin-hooks.md +24 -24
  8. package/docs/en/components/register-esbuild-plugin.mdx +2 -2
  9. package/docs/en/guide/advance/asset.mdx +8 -27
  10. package/docs/en/guide/advance/build-umd.mdx +18 -66
  11. package/docs/en/guide/advance/external-dependency.mdx +7 -27
  12. package/docs/en/guide/advance/in-depth-about-build.md +4 -4
  13. package/docs/en/guide/advance/in-depth-about-dev-command.md +2 -2
  14. package/docs/en/guide/advance/theme-config.mdx +4 -8
  15. package/docs/en/guide/basic/before-getting-started.md +1 -1
  16. package/docs/en/guide/basic/publish-your-project.md +8 -7
  17. package/docs/en/guide/basic/test-your-project.mdx +10 -47
  18. package/docs/en/guide/basic/use-micro-generator.md +4 -4
  19. package/docs/en/guide/basic/using-storybook.mdx +12 -44
  20. package/docs/en/guide/best-practices/components.mdx +44 -402
  21. package/docs/en/guide/faq/build.mdx +16 -0
  22. package/docs/en/guide/intro/getting-started.md +21 -2
  23. package/docs/en/plugins/guide/getting-started.mdx +8 -24
  24. package/docs/en/plugins/guide/plugin-object.mdx +2 -8
  25. package/docs/en/plugins/official-list/plugin-import.mdx +9 -52
  26. package/docs/en/plugins/official-list/plugin-node-polyfill.md +2 -2
  27. package/docs/zh/api/config/build-config.mdx +83 -56
  28. package/docs/zh/api/config/build-preset.mdx +12 -30
  29. package/docs/zh/api/config/design-system.md +6 -6
  30. package/docs/zh/api/config/plugins.md +3 -3
  31. package/docs/zh/api/config/testing.md +2 -2
  32. package/docs/zh/components/register-esbuild-plugin.mdx +2 -2
  33. package/docs/zh/guide/advance/asset.mdx +9 -30
  34. package/docs/zh/guide/advance/build-umd.mdx +19 -67
  35. package/docs/zh/guide/advance/external-dependency.mdx +8 -28
  36. package/docs/zh/guide/advance/in-depth-about-build.md +4 -4
  37. package/docs/zh/guide/advance/in-depth-about-dev-command.md +2 -2
  38. package/docs/zh/guide/advance/theme-config.mdx +4 -8
  39. package/docs/zh/guide/basic/publish-your-project.md +2 -2
  40. package/docs/zh/guide/basic/test-your-project.mdx +11 -49
  41. package/docs/zh/guide/basic/use-micro-generator.md +4 -4
  42. package/docs/zh/guide/basic/using-storybook.mdx +13 -45
  43. package/docs/zh/guide/best-practices/components.mdx +50 -410
  44. package/docs/zh/guide/faq/build.mdx +16 -0
  45. package/docs/zh/guide/intro/getting-started.md +20 -1
  46. package/docs/zh/plugins/guide/getting-started.mdx +8 -24
  47. package/docs/zh/plugins/guide/plugin-object.mdx +2 -8
  48. package/docs/zh/plugins/official-list/plugin-import.mdx +10 -55
  49. package/docs/zh/plugins/official-list/plugin-node-polyfill.md +2 -2
  50. package/modern.config.ts +1 -12
  51. package/package.json +3 -5
  52. package/theme/index.ts +0 -2
  53. package/theme/index.css +0 -9
@@ -34,24 +34,9 @@ Module Tools 集成了 Storybook,因此你几乎可以按照 Storybook 官方
34
34
 
35
35
  ### 引用组件产物
36
36
 
37
- 假如存在 TypeScript 项目 `foo`:
37
+ 假如存在 TypeScript 项目 `foo`,首先要确保 `package.json` 的 `main` 和 `types` 的值为正确的产物路径。
38
38
 
39
- <CH.Spotlight>
40
-
41
- ```json package.json
42
- {
43
- "name": "foo",
44
- "main": "./dist/index.js",
45
- "types": "./dist/types/index.d.ts"
46
- }
47
- ```
48
-
49
- ---
50
-
51
- 确保 `package.json` 的 `main` 和 `types`
52
- 的值为正确的产物路径。
53
-
54
- ```json package.json
39
+ ```json title="package.json"
55
40
  {
56
41
  "name": "foo",
57
42
  "main": "./dist/index.js",
@@ -59,20 +44,15 @@ Module Tools 集成了 Storybook,因此你几乎可以按照 Storybook 官方
59
44
  }
60
45
  ```
61
46
 
62
- ---
63
-
64
- `foo` 项目的源码。
47
+ `foo` 项目的源码:
65
48
 
66
- ```ts src/index.ts
49
+ ```ts title="src/index.ts"
67
50
  export const content = 'hello world';
68
51
  ```
69
52
 
70
- ---
71
-
72
- 确保在 `stories/tsconfig.json` 中设置了指向项目根目录的 `paths` 配置。
73
- `paths` 的 `key` 与项目名称相同,这样在编译过程中以及在代码中不会出现问题。
53
+ 请确保在 `stories/tsconfig.json` 中设置了指向项目根目录的 `paths` 配置。`paths` 的 `key` 与项目名称相同,这样在编译过程中以及在代码中不会出现问题。
74
54
 
75
- ```json stories/tsconfig.json focus=5:7
55
+ ```json title="stories/tsconfig.json"
76
56
  {
77
57
  "extends": "../tsconfig.json",
78
58
  "compilerOptions": {
@@ -88,11 +68,9 @@ export const content = 'hello world';
88
68
  }
89
69
  ```
90
70
 
91
- ---
92
-
93
- 在 Story 代码中直接以项目名称的方式引用。
71
+ 在 Story 代码中直接以项目名称的方式引用:
94
72
 
95
- ```tsx stories/index.stories.tsx focus=1:1
73
+ ```tsx title="stories/index.stories.tsx"
96
74
  import { content } from 'foo';
97
75
 
98
76
  const Component = () => <div>this is a Story Component {content}</div>;
@@ -104,34 +82,24 @@ export default {
104
82
  };
105
83
  ```
106
84
 
107
- ---
108
-
109
- 最后在执行命令的时候,先启动监听模式的源码构建,然后启动 Storybook 调试。
110
-
111
- <CH.Code>
85
+ 最后在执行命令的时候,先启动监听模式的源码构建,然后启动 Storybook 调试即可:
112
86
 
113
- ``` bash terminal-1
87
+ ```bash title="terminal-1"
114
88
  ## 源码构建
115
89
  modern build --watch
116
90
  ```
117
91
 
118
- ---
119
-
120
- ``` bash terminal-2
92
+ ```bash title="terminal-2"
121
93
  ## Storybook 调试
122
94
  modern dev storybook
123
95
  ```
124
96
 
125
- </CH.Code>
126
-
127
- </CH.Spotlight>
128
-
129
97
  :::info
130
98
  在开发过程中,可能会遇到无法实时获得类型定义的情况。因为只有当保存代码后,产物目录下的类型文件才会更新。此时:
131
99
 
132
100
  对于 `pnpm` 的项目,可以按照下面的内容对 `package.json` 进行修改:
133
101
 
134
- ```ts focus=4:7
102
+ ```ts
135
103
  {
136
104
  "name": "foo",
137
105
  "main": "./dist/index.js",
@@ -156,7 +124,7 @@ modern dev storybook
156
124
 
157
125
  引用组件的源码可以通过相对路径的方式:
158
126
 
159
- ```ts ./stories/index.tsx
127
+ ```ts title="./stories/index.tsx"
160
128
  import { content } from '../src';
161
129
 
162
130
  const Component = () => <div>this is a Story Component {content}</div>;