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