@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.
- package/.eslintrc.js +13 -0
- package/docs/en/api/config/_category_.json +4 -0
- package/docs/en/api/{build-config.md → config/build-config.md} +198 -105
- package/docs/en/api/{build-preset.md → config/build-preset.md} +65 -46
- package/docs/{zh/api → en/api/config}/design-system.md +130 -127
- package/docs/en/api/config/plugins.md +18 -0
- package/docs/en/api/{test.md → config/testing.md} +21 -12
- package/docs/en/api/index.md +3 -1
- package/docs/en/api/plugin-api/_category_.json +4 -0
- package/docs/en/api/plugin-api/plugin-hooks.md +501 -0
- package/docs/en/guide/advance/_category_.json +4 -0
- package/docs/en/guide/advance/asset.mdx +47 -30
- package/docs/en/guide/advance/build-umd.mdx +88 -80
- package/docs/en/guide/advance/copy.md +31 -28
- package/docs/en/guide/advance/external-dependency.mdx +27 -23
- package/docs/en/guide/advance/in-depth-about-build.md +56 -50
- package/docs/en/guide/advance/in-depth-about-dev-command.md +7 -4
- package/docs/en/guide/advance/theme-config.mdx +80 -0
- package/docs/en/guide/basic/_category_.json +4 -0
- package/docs/en/guide/basic/before-getting-started.md +28 -23
- package/docs/en/guide/basic/command-preview.md +18 -14
- package/docs/en/guide/basic/modify-output-product.md +27 -20
- package/docs/en/guide/basic/publish-your-project.md +21 -19
- package/docs/en/guide/basic/test-your-project.mdx +19 -16
- package/docs/en/guide/basic/use-micro-generator.md +10 -7
- package/docs/en/guide/basic/using-storybook.mdx +27 -26
- package/docs/en/guide/best-practices/_category_.json +4 -0
- package/docs/en/guide/best-practices/components.mdx +783 -0
- package/docs/en/guide/intro/_category_.json +4 -0
- package/docs/en/guide/intro/getting-started.md +9 -4
- package/docs/en/guide/intro/welcome.md +4 -0
- package/docs/en/guide/intro/why-module-engineering-solution.md +5 -1
- package/docs/en/index.md +3 -5
- package/docs/en/plugins/guide/_category_.json +4 -0
- package/docs/en/plugins/guide/getting-started.mdx +84 -0
- package/docs/en/plugins/guide/plugin-object.mdx +85 -0
- package/docs/en/plugins/guide/setup-function.mdx +117 -0
- package/docs/en/plugins/official-list/_category_.json +4 -0
- package/docs/en/plugins/official-list/overview.md +6 -0
- package/docs/zh/api/config/_category_.json +4 -0
- package/docs/zh/api/config/build-config.md +658 -0
- package/docs/zh/api/{build-preset.md → config/build-preset.md} +49 -36
- package/docs/zh/api/config/design-system.md +1166 -0
- package/docs/zh/api/config/plugins.md +18 -0
- package/docs/zh/api/{testing.md → config/testing.md} +18 -13
- package/docs/zh/api/index.md +4 -1
- package/docs/zh/api/plugin-api/_category_.json +4 -0
- package/docs/zh/api/plugin-api/plugin-hooks.md +500 -0
- package/docs/zh/guide/advance/_category_.json +4 -0
- package/docs/zh/guide/advance/asset.mdx +47 -30
- package/docs/zh/guide/advance/build-umd.mdx +88 -71
- package/docs/zh/guide/advance/copy.md +31 -28
- package/docs/zh/guide/advance/external-dependency.mdx +27 -23
- package/docs/zh/guide/advance/in-depth-about-build.md +55 -50
- package/docs/zh/guide/advance/in-depth-about-dev-command.md +7 -4
- package/docs/zh/guide/advance/theme-config.mdx +78 -0
- package/docs/zh/guide/basic/_category_.json +4 -0
- package/docs/zh/guide/basic/before-getting-started.md +27 -22
- package/docs/zh/guide/basic/command-preview.md +17 -13
- package/docs/zh/guide/basic/modify-output-product.md +28 -21
- package/docs/zh/guide/basic/publish-your-project.md +22 -17
- package/docs/zh/guide/basic/test-your-project.mdx +20 -16
- package/docs/zh/guide/basic/use-micro-generator.md +10 -7
- package/docs/zh/guide/basic/using-storybook.mdx +27 -24
- package/docs/zh/guide/best-practices/_category_.json +4 -0
- package/docs/zh/guide/best-practices/components.mdx +793 -0
- package/docs/zh/guide/intro/_category_.json +4 -0
- package/docs/zh/guide/intro/getting-started.md +10 -4
- package/docs/zh/guide/intro/welcome.md +4 -0
- package/docs/zh/guide/intro/why-module-engineering-solution.md +5 -1
- package/docs/zh/index.md +3 -2
- package/docs/zh/plugins/guide/_category_.json +4 -0
- package/docs/zh/plugins/guide/getting-started.mdx +84 -0
- package/docs/zh/plugins/guide/plugin-object.mdx +85 -0
- package/docs/zh/plugins/guide/setup-function.mdx +117 -0
- package/docs/zh/plugins/official-list/_category_.json +4 -0
- package/docs/zh/plugins/official-list/overview.md +5 -0
- package/modern.config.ts +118 -0
- package/package.json +8 -6
- package/{docs/.island/styles → theme}/index.css +0 -1
- package/theme/index.ts +4 -0
- package/tsconfig.json +7 -0
- package/docs/.island/config.ts +0 -245
- package/docs/.island/dist/404.html +0 -41
- package/docs/.island/dist/assets/before-getting-started.1b82b538.js +0 -87
- package/docs/.island/dist/assets/before-getting-started.582a31cc.js +0 -87
- package/docs/.island/dist/assets/build-config.72eb0918.js +0 -804
- package/docs/.island/dist/assets/build-config.d8bb1658.js +0 -809
- package/docs/.island/dist/assets/build-preset.96805d7d.js +0 -256
- package/docs/.island/dist/assets/build-preset.c20dcd40.js +0 -256
- package/docs/.island/dist/assets/build-your-ui.7f349247.js +0 -2
- package/docs/.island/dist/assets/build-your-ui.a8361604.js +0 -2
- package/docs/.island/dist/assets/command-preview.2d45fc82.js +0 -264
- package/docs/.island/dist/assets/command-preview.dc51b953.js +0 -264
- package/docs/.island/dist/assets/components.esm.03560353.js +0 -9
- package/docs/.island/dist/assets/design-system.86694ff5.js +0 -1254
- package/docs/.island/dist/assets/design-system.c4745cce.js +0 -639
- package/docs/.island/dist/assets/dev.1d326a37.js +0 -37
- package/docs/.island/dist/assets/dev.1fd06000.js +0 -37
- package/docs/.island/dist/assets/down.f35427d3.svg +0 -1
- package/docs/.island/dist/assets/extension.12299fd6.js +0 -2
- package/docs/.island/dist/assets/extension.96dc63a4.js +0 -2
- package/docs/.island/dist/assets/getting-started.40e9218d.js +0 -117
- package/docs/.island/dist/assets/getting-started.b1ed3f10.js +0 -114
- package/docs/.island/dist/assets/github.3bf8ccee.svg +0 -1
- package/docs/.island/dist/assets/index.2b2347ea.js +0 -33
- package/docs/.island/dist/assets/index.6cef6f5f.js +0 -4
- package/docs/.island/dist/assets/index.cb118238.js +0 -36
- package/docs/.island/dist/assets/index.ccb6ce27.js +0 -4
- package/docs/.island/dist/assets/island_inject.11a12ecc.js +0 -1
- package/docs/.island/dist/assets/island_inject.b13deaee.js +0 -1
- package/docs/.island/dist/assets/loading.8c9bb911.svg +0 -1
- package/docs/.island/dist/assets/modify-output-product.7f6bff35.js +0 -100
- package/docs/.island/dist/assets/modify-output-product.b91eff1f.js +0 -100
- package/docs/.island/dist/assets/moon.6b705924.svg +0 -3
- package/docs/.island/dist/assets/plugin.895932d8.js +0 -42
- package/docs/.island/dist/assets/plugin.d2fbc531.js +0 -42
- package/docs/.island/dist/assets/publish-your-project.21b8309f.js +0 -164
- package/docs/.island/dist/assets/publish-your-project.8d398b17.js +0 -166
- package/docs/.island/dist/assets/right.89674cd7.svg +0 -1
- package/docs/.island/dist/assets/search.0aea6901.svg +0 -1
- package/docs/.island/dist/assets/search.1c85d17c.js +0 -3
- package/docs/.island/dist/assets/search.484eca11.js +0 -222
- package/docs/.island/dist/assets/search.54fca8d0.js +0 -3
- package/docs/.island/dist/assets/style.09015a4b.css +0 -1
- package/docs/.island/dist/assets/style.2e5f7bc2.css +0 -1970
- package/docs/.island/dist/assets/sun.841dac10.svg +0 -11
- package/docs/.island/dist/assets/test-your-project.18bd4582.js +0 -190
- package/docs/.island/dist/assets/test-your-project.f53bebf7.js +0 -190
- package/docs/.island/dist/assets/test.0da1f99f.js +0 -67
- package/docs/.island/dist/assets/test.0e81f002.js +0 -66
- package/docs/.island/dist/assets/translator.b1077c44.svg +0 -1
- package/docs/.island/dist/assets/use-micro-generator.7d9e4016.js +0 -60
- package/docs/.island/dist/assets/use-micro-generator.db5520c1.js +0 -60
- package/docs/.island/dist/assets/using-storybook.57ea6b77.js +0 -260
- package/docs/.island/dist/assets/using-storybook.a2212f2e.js +0 -260
- package/docs/.island/dist/assets/welcome.0449a9c8.js +0 -13
- package/docs/.island/dist/assets/welcome.a8448931.js +0 -13
- package/docs/.island/dist/assets/why-module-engineering-solution.6ae8c0e3.js +0 -26
- package/docs/.island/dist/assets/why-module-engineering-solution.c9a45cbd.js +0 -26
- package/docs/.island/dist/chunk-COLCRJ2V.js +0 -1
- package/docs/.island/dist/chunk-K5FMOYDC.js +0 -10
- package/docs/.island/dist/chunk-WE42KMYS.js +0 -26
- package/docs/.island/dist/client-entry.js +0 -3
- package/docs/.island/dist/en/api/build-config.html +0 -344
- package/docs/.island/dist/en/api/build-preset.html +0 -82
- package/docs/.island/dist/en/api/design-system.html +0 -155
- package/docs/.island/dist/en/api/dev.html +0 -45
- package/docs/.island/dist/en/api/index.html +0 -41
- package/docs/.island/dist/en/api/plugin.html +0 -48
- package/docs/.island/dist/en/api/test.html +0 -58
- package/docs/.island/dist/en/guide/before-getting-started.html +0 -127
- package/docs/.island/dist/en/guide/build-your-ui.html +0 -41
- package/docs/.island/dist/en/guide/command-preview.html +0 -100
- package/docs/.island/dist/en/guide/extension.html +0 -41
- package/docs/.island/dist/en/guide/getting-started.html +0 -76
- package/docs/.island/dist/en/guide/modify-output-product.html +0 -140
- package/docs/.island/dist/en/guide/publish-your-project.html +0 -91
- package/docs/.island/dist/en/guide/test-your-project.html +0 -72
- package/docs/.island/dist/en/guide/use-micro-generator.html +0 -65
- package/docs/.island/dist/en/guide/using-storybook.html +0 -113
- package/docs/.island/dist/en/guide/welcome.html +0 -53
- package/docs/.island/dist/en/guide/why-module-engineering-solution.html +0 -49
- package/docs/.island/dist/en/index.html +0 -42
- package/docs/.island/dist/react-dom.js +0 -1
- package/docs/.island/dist/react-dom_client.js +0 -1
- package/docs/.island/dist/react.js +0 -1
- package/docs/.island/dist/react_jsx-runtime.js +0 -10
- package/docs/.island/dist/ssr-manifest.json +0 -57
- 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 +0 -347
- package/docs/.island/dist/zh/api/build-preset.html +0 -82
- package/docs/.island/dist/zh/api/design-system.html +0 -149
- package/docs/.island/dist/zh/api/dev.html +0 -46
- package/docs/.island/dist/zh/api/index.html +0 -41
- package/docs/.island/dist/zh/api/plugin.html +0 -48
- package/docs/.island/dist/zh/api/test.html +0 -59
- package/docs/.island/dist/zh/guide/before-getting-started.html +0 -127
- package/docs/.island/dist/zh/guide/build-your-ui.html +0 -41
- package/docs/.island/dist/zh/guide/command-preview.html +0 -100
- package/docs/.island/dist/zh/guide/extension.html +0 -41
- package/docs/.island/dist/zh/guide/getting-started.html +0 -79
- package/docs/.island/dist/zh/guide/modify-output-product.html +0 -140
- package/docs/.island/dist/zh/guide/publish-your-project.html +0 -92
- package/docs/.island/dist/zh/guide/test-your-project.html +0 -72
- package/docs/.island/dist/zh/guide/use-micro-generator.html +0 -65
- package/docs/.island/dist/zh/guide/using-storybook.html +0 -114
- package/docs/.island/dist/zh/guide/welcome.html +0 -53
- package/docs/.island/dist/zh/guide/why-module-engineering-solution.html +0 -49
- package/docs/.island/dist/zh/index.html +0 -42
- package/docs/.island/index.html +0 -39
- package/docs/en/api/design-system.md +0 -524
- package/docs/en/api/dev.md +0 -32
- package/docs/en/api/plugin.md +0 -34
- package/docs/zh/api/build-config.md +0 -570
- package/docs/zh/api/dev.md +0 -33
- package/docs/zh/api/plugins.md +0 -108
|
@@ -1,56 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
---
|
|
4
|
+
|
|
1
5
|
# BuildPreset
|
|
6
|
+
|
|
2
7
|
A build preset string or preset function. Provides out-of-the-box build configuration
|
|
3
8
|
|
|
4
9
|
- type: `string | Function`
|
|
5
10
|
- default: `undefined`
|
|
6
11
|
|
|
7
|
-
|
|
8
12
|
## string
|
|
9
13
|
|
|
10
14
|
The string form allows you to use the built-in presets directly
|
|
11
15
|
|
|
12
|
-
```js
|
|
13
|
-
|
|
16
|
+
```js modern.config.ts
|
|
17
|
+
import { defineConfig } from '@modern-js/module-tools';
|
|
18
|
+
|
|
19
|
+
export default defineConfig({
|
|
14
20
|
buildPreset: 'npm-library',
|
|
15
|
-
};
|
|
21
|
+
});
|
|
16
22
|
```
|
|
17
23
|
|
|
18
|
-
|
|
19
24
|
### ``npm-library'`
|
|
25
|
+
|
|
20
26
|
Library generic schema used under class [NPM](https://www.npmjs.com/) package manager, contains `esm` and `cjs` Bundle products, and includes a type file.
|
|
21
27
|
|
|
22
28
|
:::info
|
|
23
29
|
About the class [NPM](https://www.npmjs.com/) Package Manager
|
|
24
|
-
* [npm](https://www.npmjs.com)
|
|
25
|
-
* [yarn](https://yarnpkg.com/)
|
|
26
|
-
* [pnpm](https://pnpm.io/)
|
|
27
|
-
:::
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
- [npm](https://www.npmjs.com)
|
|
32
|
+
- [yarn](https://yarnpkg.com/)
|
|
33
|
+
- [pnpm](https://pnpm.io/)
|
|
34
|
+
:::
|
|
35
|
+
|
|
36
|
+
```json package.json
|
|
30
37
|
{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
"main": ". /dist/lib/index.js",
|
|
39
|
+
"module": ". /dist/es/index.js",
|
|
40
|
+
"types": ". /dist/types/index.d.ts"
|
|
34
41
|
}
|
|
35
42
|
```
|
|
43
|
+
|
|
36
44
|
The build configuration corresponding to the preset string.
|
|
45
|
+
|
|
37
46
|
```js
|
|
38
47
|
export const buildConfig = [
|
|
39
48
|
{
|
|
40
49
|
format: 'cjs',
|
|
41
50
|
target: 'es6',
|
|
42
51
|
buildType: 'bundle',
|
|
43
|
-
|
|
52
|
+
outDir: '. /lib',
|
|
44
53
|
},
|
|
45
54
|
{
|
|
46
55
|
format: 'esm',
|
|
47
56
|
target: 'es6',
|
|
48
57
|
buildType: 'bundle',
|
|
49
|
-
|
|
58
|
+
outDir: '. /es',
|
|
50
59
|
},
|
|
51
60
|
{
|
|
52
61
|
buildType: 'bundle',
|
|
53
|
-
|
|
62
|
+
outDir: '. /types',
|
|
54
63
|
dts: {
|
|
55
64
|
only: true,
|
|
56
65
|
},
|
|
@@ -58,10 +67,11 @@ export const buildConfig = [
|
|
|
58
67
|
];
|
|
59
68
|
```
|
|
60
69
|
|
|
61
|
-
###
|
|
62
|
-
|
|
70
|
+
### `npm-library-with-umd'`
|
|
71
|
+
|
|
72
|
+
Used under class [NPM](https://www.npmjs.com/) package manager, and Library supports a similar pattern to [unpkg](https://unpkg.com/). Additional `umd` products are provided on top of the pre-defined `npm-library`.
|
|
63
73
|
|
|
64
|
-
```json
|
|
74
|
+
```json package.json
|
|
65
75
|
{
|
|
66
76
|
"main": ". /dist/lib/index.js",
|
|
67
77
|
"module": ". /dist/es/index.js",
|
|
@@ -69,30 +79,32 @@ Used under class [NPM](https://www.npmjs.com/) package manager, and Library supp
|
|
|
69
79
|
"unpkg": ". /dist/umd/index.js",
|
|
70
80
|
};
|
|
71
81
|
```
|
|
82
|
+
|
|
72
83
|
The build configuration corresponding to the preset string.
|
|
84
|
+
|
|
73
85
|
```js
|
|
74
86
|
export const buildConfig = [
|
|
75
87
|
{
|
|
76
88
|
format: 'cjs',
|
|
77
89
|
target: 'es6',
|
|
78
90
|
buildType: 'bundle',
|
|
79
|
-
|
|
91
|
+
outDir: '. /lib',
|
|
80
92
|
},
|
|
81
93
|
{
|
|
82
94
|
format: 'esm',
|
|
83
95
|
target: 'es6',
|
|
84
96
|
buildType: 'bundle',
|
|
85
|
-
|
|
97
|
+
outDir: '. /es',
|
|
86
98
|
},
|
|
87
99
|
{
|
|
88
100
|
format: 'umd',
|
|
89
101
|
target: 'es6',
|
|
90
102
|
buildType: 'bundle',
|
|
91
|
-
|
|
103
|
+
outDir: '. /umd',
|
|
92
104
|
},
|
|
93
105
|
{
|
|
94
106
|
buildType: 'bundle',
|
|
95
|
-
|
|
107
|
+
outDir: '. /types',
|
|
96
108
|
dts: {
|
|
97
109
|
only: true,
|
|
98
110
|
},
|
|
@@ -101,36 +113,38 @@ export const buildConfig = [
|
|
|
101
113
|
```
|
|
102
114
|
|
|
103
115
|
### `'npm-component'`
|
|
104
|
-
|
|
116
|
+
|
|
117
|
+
A generic pattern for components (libraries) used under the class [NPM](https://www.npmjs.com/) package manager. Contains both `esm` and `cjs` Bundleless products (for easy _[Tree shaking](https://developer.mozilla.org/zh-CN/docs/Glossary/Tree_shaking)_ optimization), as well as including a copy of the type file.
|
|
105
118
|
|
|
106
119
|
For style files included in the source code, the products provide the compiled product of the style and the source file of the style.
|
|
107
120
|
|
|
108
|
-
```json
|
|
121
|
+
```json package.json
|
|
109
122
|
{
|
|
110
123
|
"main": ". /dist/lib/index.js", // bundleless type
|
|
111
124
|
"module": ". /dist/es/index.js", // bundleless type
|
|
112
125
|
"types": ". /dist/types/index.d.ts",
|
|
113
126
|
};
|
|
114
127
|
```
|
|
128
|
+
|
|
115
129
|
The pre-defined strings correspond to the build configuration.
|
|
116
130
|
|
|
117
|
-
```
|
|
131
|
+
```js
|
|
118
132
|
export const buildConfig = [
|
|
119
133
|
{
|
|
120
134
|
format: 'cjs',
|
|
121
135
|
target: 'es6',
|
|
122
136
|
buildType: 'bundleless',
|
|
123
|
-
|
|
137
|
+
outDir: '. /lib',
|
|
124
138
|
},
|
|
125
139
|
{
|
|
126
140
|
format: 'esm',
|
|
127
141
|
target: 'es6',
|
|
128
142
|
buildType: 'bundleless',
|
|
129
|
-
|
|
143
|
+
outDir: '. /es',
|
|
130
144
|
},
|
|
131
145
|
{
|
|
132
146
|
buildType: 'bundleless',
|
|
133
|
-
|
|
147
|
+
outDir: '. /types',
|
|
134
148
|
dts: {
|
|
135
149
|
only: true,
|
|
136
150
|
},
|
|
@@ -140,8 +154,9 @@ export const buildConfig = [
|
|
|
140
154
|
|
|
141
155
|
### `'npm-component-with-umd'`
|
|
142
156
|
|
|
143
|
-
Component (library) used under class [NPM](https://www.npmjs.com/) package manager, with support for class [unpkg](https://unpkg.com/) schema. Additional
|
|
144
|
-
|
|
157
|
+
Component (library) used under class [NPM](https://www.npmjs.com/) package manager, with support for class [unpkg](https://unpkg.com/) schema. Additional `umd` products are provided on top of the pre-defined `npm-component`.
|
|
158
|
+
|
|
159
|
+
```json package.json
|
|
145
160
|
{
|
|
146
161
|
"main": ". /dist/lib/index.js", // bundleless type
|
|
147
162
|
"module": ". /dist/es/index.js", // bundleless type
|
|
@@ -149,29 +164,30 @@ Component (library) used under class [NPM](https://www.npmjs.com/) package manag
|
|
|
149
164
|
"unpkg": ". /dist/umd/index.js",
|
|
150
165
|
};
|
|
151
166
|
```
|
|
167
|
+
|
|
152
168
|
```js
|
|
153
169
|
export const buildConfig = [
|
|
154
170
|
{
|
|
155
171
|
format: 'cjs',
|
|
156
172
|
target: 'es6',
|
|
157
173
|
buildType: 'bundleless',
|
|
158
|
-
|
|
174
|
+
outDir: '. /lib',
|
|
159
175
|
},
|
|
160
176
|
{
|
|
161
177
|
format: 'esm',
|
|
162
178
|
target: 'es6',
|
|
163
179
|
buildType: 'bundleless',
|
|
164
|
-
|
|
180
|
+
outDir: '. /es',
|
|
165
181
|
},
|
|
166
|
-
|
|
182
|
+
{
|
|
167
183
|
format: 'umd',
|
|
168
184
|
target: 'es6',
|
|
169
185
|
buildType: 'bundle',
|
|
170
|
-
|
|
186
|
+
outDir: '. /umd',
|
|
171
187
|
},
|
|
172
188
|
{
|
|
173
189
|
buildType: 'bundleless',
|
|
174
|
-
|
|
190
|
+
outDir: '. /types',
|
|
175
191
|
dts: {
|
|
176
192
|
only: true,
|
|
177
193
|
},
|
|
@@ -179,26 +195,29 @@ export const buildConfig = [
|
|
|
179
195
|
];
|
|
180
196
|
```
|
|
181
197
|
|
|
182
|
-
### About the ECMAScript versions supported by the
|
|
183
|
-
|
|
198
|
+
### About the ECMAScript versions supported by the presets and `{es5.... .esnext}`
|
|
184
199
|
|
|
185
200
|
When you want to use a `buildPreset` preset that supports other ECMAScript versions, you can directly add the supported versions to the `'npm-library'`, `'npm-library-with-umd'`, `'npm-component'`, `'npm-component-with-umd'` presets.
|
|
186
201
|
|
|
187
|
-
For example, if you want the ``npm-library'` preset to support
|
|
202
|
+
For example, if you want the `` npm-library'` preset to support ``es2017``, you can configure it as follows.
|
|
188
203
|
|
|
189
|
-
```js
|
|
190
|
-
|
|
204
|
+
```js modern.config.ts
|
|
205
|
+
import { defineConfig } from '@modern-js/module-tools';
|
|
206
|
+
|
|
207
|
+
export default defineConfig({
|
|
191
208
|
buildPreset: 'npm-library-es2017',
|
|
192
|
-
};
|
|
209
|
+
});
|
|
193
210
|
```
|
|
194
211
|
|
|
195
212
|
## Function
|
|
196
213
|
|
|
197
|
-
The way the function is configured, you can get the preset value
|
|
214
|
+
The way the function is configured, you can get the preset value from the `preset` parameter and then modify the build configuration inside to customize your build configuration.
|
|
198
215
|
The following is an example of how a function can be configured to compress a build product.
|
|
199
216
|
|
|
200
|
-
```js
|
|
201
|
-
|
|
217
|
+
```js modern.config.ts
|
|
218
|
+
import { defineConfig } from '@modern-js/module-tools';
|
|
219
|
+
|
|
220
|
+
export default defineConfig({
|
|
202
221
|
buildPreset({ preset }) {
|
|
203
222
|
const { NPM_LIBRARY } = preset;
|
|
204
223
|
return NPM_LIBRARY.map(config => {
|
|
@@ -210,5 +229,5 @@ export default {
|
|
|
210
229
|
return config;
|
|
211
230
|
});
|
|
212
231
|
},
|
|
213
|
-
}
|
|
232
|
+
});
|
|
214
233
|
```
|