@modern-js/module-tools-docs 2.24.1 → 2.25.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.
- package/CHANGELOG.md +9 -3
- package/docs/en/api/config/build-config.md +43 -2
- package/docs/en/api/plugin-api/plugin-hooks.md +13 -13
- package/docs/en/guide/advance/in-depth-about-dev-command.md +1 -1
- package/docs/en/guide/basic/before-getting-started.md +2 -2
- package/docs/en/guide/basic/modify-output-product.md +2 -2
- package/docs/en/guide/basic/use-micro-generator.md +8 -8
- package/docs/en/guide/intro/getting-started.md +1 -1
- package/docs/en/plugins/guide/setup-function.mdx +3 -3
- package/docs/en/plugins/official-list/plugin-babel.md +2 -2
- package/docs/en/plugins/official-list/plugin-banner.md +2 -2
- package/docs/en/plugins/official-list/plugin-import.mdx +4 -4
- package/docs/en/plugins/official-list/plugin-node-polyfill.md +3 -3
- package/docs/en/plugins/official-list/plugin-polyfill.md +2 -2
- package/docs/zh/api/config/build-config.md +42 -2
- package/docs/zh/api/plugin-api/plugin-hooks.md +13 -13
- package/docs/zh/guide/advance/in-depth-about-dev-command.md +1 -1
- package/docs/zh/guide/basic/before-getting-started.md +2 -2
- package/docs/zh/guide/basic/modify-output-product.md +2 -2
- package/docs/zh/guide/basic/test-your-project.mdx +3 -3
- package/docs/zh/guide/basic/use-micro-generator.md +8 -8
- package/docs/zh/guide/intro/getting-started.md +1 -1
- package/docs/zh/plugins/guide/setup-function.mdx +3 -3
- package/docs/zh/plugins/official-list/plugin-babel.md +2 -2
- package/docs/zh/plugins/official-list/plugin-banner.md +2 -2
- package/docs/zh/plugins/official-list/plugin-import.mdx +5 -5
- package/docs/zh/plugins/official-list/plugin-node-polyfill.md +3 -3
- package/docs/zh/plugins/official-list/plugin-polyfill.md +2 -2
- package/modern.config.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# @modern-js/module-tools-docs
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.25.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ba6f5a6: docs: update module doc FAQ contents
|
|
8
|
+
docs: 更新 module 文档的 FAQ 内容
|
|
4
9
|
|
|
5
10
|
### Patch Changes
|
|
6
11
|
|
|
7
|
-
-
|
|
8
|
-
- @modern-js/doc-tools@2.
|
|
12
|
+
- Updated dependencies [9aa2c25]
|
|
13
|
+
- @modern-js/doc-tools@2.25.0
|
|
14
|
+
- @modern-js/doc-plugin-auto-sidebar@2.25.0
|
|
9
15
|
|
|
10
16
|
## 2.24.0
|
|
11
17
|
|
|
@@ -455,6 +455,8 @@ Specify the entry file for the build, in the form of an array that can specify t
|
|
|
455
455
|
- **Type**: `string[] | Record<string, string>`
|
|
456
456
|
- **Default**: `['src/index.ts']` in `bundle` mode, `['src']` in `bundleless` mode
|
|
457
457
|
|
|
458
|
+
**Array usage:**
|
|
459
|
+
|
|
458
460
|
```js modern.config.ts
|
|
459
461
|
export default {
|
|
460
462
|
buildConfig: {
|
|
@@ -463,11 +465,34 @@ export default {
|
|
|
463
465
|
};
|
|
464
466
|
```
|
|
465
467
|
|
|
468
|
+
**Object usage:**
|
|
469
|
+
|
|
470
|
+
When you need to modify the output file name in bundle mode, you can use an object configuration.
|
|
471
|
+
|
|
472
|
+
**The key of the object is the file name of the output, and the value is the file path of the source code.**
|
|
473
|
+
|
|
474
|
+
```js modern.config.ts
|
|
475
|
+
export default defineConfig({
|
|
476
|
+
buildConfig: {
|
|
477
|
+
format: 'esm',
|
|
478
|
+
input: {
|
|
479
|
+
'index.esm': './src/index.ts',
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
```
|
|
484
|
+
|
|
466
485
|
## jsx
|
|
467
486
|
|
|
468
|
-
Specify the compilation method of
|
|
487
|
+
Specify the compilation method of JSX, default support React17, automatically inject JSX Runtime code. If you need to support React16, set `jsx` to `transform`.
|
|
469
488
|
|
|
470
|
-
|
|
489
|
+
> For more information about JSX Transform, you can refer to the following links:
|
|
490
|
+
>
|
|
491
|
+
> - [React Blog](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)。
|
|
492
|
+
> - [esbuild JSX](https://esbuild.github.io/api/#jsx)
|
|
493
|
+
>
|
|
494
|
+
|
|
495
|
+
- **Type**: `automatic | transform`
|
|
471
496
|
- **Default**: `automatic`
|
|
472
497
|
|
|
473
498
|
## metafile
|
|
@@ -744,6 +769,22 @@ export default {
|
|
|
744
769
|
|
|
745
770
|
See [PostCSS](https://github.com/postcss/postcss#options) for detailed configuration
|
|
746
771
|
|
|
772
|
+
**Basic usage:**
|
|
773
|
+
|
|
774
|
+
``` js modern.config.ts
|
|
775
|
+
export default defineConfig({
|
|
776
|
+
buildConfig: {
|
|
777
|
+
style: {
|
|
778
|
+
postcss: {
|
|
779
|
+
plugins: [
|
|
780
|
+
yourPostCSSPlugin,
|
|
781
|
+
],
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
},
|
|
785
|
+
});
|
|
786
|
+
```
|
|
787
|
+
|
|
747
788
|
## style.inject
|
|
748
789
|
|
|
749
790
|
Configure whether to insert CSS styles into JavaScript code in bundle mode.
|
|
@@ -22,7 +22,7 @@ The following Hooks are triggered in order when the `build` command is executed.
|
|
|
22
22
|
Triggered before the execution of the overall build process.
|
|
23
23
|
|
|
24
24
|
``` ts
|
|
25
|
-
export
|
|
25
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
26
26
|
name: 'my-plugin',
|
|
27
27
|
|
|
28
28
|
setup() {
|
|
@@ -59,7 +59,7 @@ type Return = BuildConfig;
|
|
|
59
59
|
Based on the build configuration, Module Tools will split the overall build into multiple sub-build tasks. The Hook will be triggered before each build subtask.
|
|
60
60
|
|
|
61
61
|
``` ts
|
|
62
|
-
export
|
|
62
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
63
63
|
name: 'my-plugin',
|
|
64
64
|
|
|
65
65
|
setup() {
|
|
@@ -81,7 +81,7 @@ Parameters and return value types.
|
|
|
81
81
|
Triggered after the end of each build subtask.
|
|
82
82
|
|
|
83
83
|
``` ts
|
|
84
|
-
export
|
|
84
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
85
85
|
name: 'my-plugin',
|
|
86
86
|
|
|
87
87
|
setup() {
|
|
@@ -109,7 +109,7 @@ export interface BuildTaskResult {
|
|
|
109
109
|
Triggered after the end of the overall build process.
|
|
110
110
|
|
|
111
111
|
``` ts
|
|
112
|
-
export
|
|
112
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
113
113
|
name: 'my-plugin',
|
|
114
114
|
|
|
115
115
|
setup() {
|
|
@@ -152,7 +152,7 @@ Hooks are triggered in the following order after executing `build --platform`.
|
|
|
152
152
|
Gets information about the tasks that need to be run when executing the `build --platform` command.
|
|
153
153
|
|
|
154
154
|
``` ts
|
|
155
|
-
export
|
|
155
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
156
156
|
name: 'my-plugin',
|
|
157
157
|
|
|
158
158
|
setup() {
|
|
@@ -188,7 +188,7 @@ export interface RegisterBuildPlatformResult {
|
|
|
188
188
|
Triggers all registered build tasks when the `build --platform` command is executed. `beforeBuildPlatform` will be triggered before the execution of the overall build task.
|
|
189
189
|
|
|
190
190
|
``` ts
|
|
191
|
-
export
|
|
191
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
192
192
|
name: 'my-plugin',
|
|
193
193
|
|
|
194
194
|
setup() {
|
|
@@ -218,7 +218,7 @@ export interface RegisterBuildPlatformResult {
|
|
|
218
218
|
When the `build --platform` command is executed, all registered build tasks will be triggered. `buildPlatform` will be triggered before each build task is executed.
|
|
219
219
|
|
|
220
220
|
``` ts
|
|
221
|
-
export
|
|
221
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
222
222
|
name: 'my-plugin',
|
|
223
223
|
|
|
224
224
|
setup() {
|
|
@@ -244,7 +244,7 @@ export interface Options {
|
|
|
244
244
|
When the `build --platform` command is executed, all registered build tasks will be triggered. `afterBuildPlatform` will be triggered after the overall platform build task is finished.
|
|
245
245
|
|
|
246
246
|
``` ts
|
|
247
|
-
export
|
|
247
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
248
248
|
name: 'my-plugin',
|
|
249
249
|
|
|
250
250
|
setup() {
|
|
@@ -292,7 +292,7 @@ Register dev tool related data. Mainly contains.
|
|
|
292
292
|
* The function to execute the dev task.
|
|
293
293
|
|
|
294
294
|
``` ts
|
|
295
|
-
export
|
|
295
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
296
296
|
name: 'my-plugin',
|
|
297
297
|
|
|
298
298
|
setup() {
|
|
@@ -346,7 +346,7 @@ The currently supported Storybook dev supports using source code products as dev
|
|
|
346
346
|
Triggered before the dev task is executed after all dev tool metadata has been collected.
|
|
347
347
|
|
|
348
348
|
``` ts
|
|
349
|
-
export
|
|
349
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
350
350
|
name: 'my-plugin',
|
|
351
351
|
|
|
352
352
|
setup() {
|
|
@@ -395,7 +395,7 @@ const question = [
|
|
|
395
395
|
`afterDevMenu` Triggered after selecting dev list/menu options.
|
|
396
396
|
|
|
397
397
|
``` ts
|
|
398
|
-
export
|
|
398
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
399
399
|
name: 'my-plugin',
|
|
400
400
|
|
|
401
401
|
setup() {
|
|
@@ -442,7 +442,7 @@ export interface DevToolData {
|
|
|
442
442
|
Triggered before the dev task is executed.
|
|
443
443
|
|
|
444
444
|
``` ts
|
|
445
|
-
export
|
|
445
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
446
446
|
name: 'my-plugin',
|
|
447
447
|
|
|
448
448
|
setup() {
|
|
@@ -477,7 +477,7 @@ export interface DevToolData {
|
|
|
477
477
|
Triggered when the dev task process is interrupted.
|
|
478
478
|
|
|
479
479
|
``` ts
|
|
480
|
-
export
|
|
480
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
481
481
|
name: 'my-plugin',
|
|
482
482
|
|
|
483
483
|
setup() {
|
|
@@ -26,7 +26,7 @@ If you need to extend the dev command, or rather provide your own Module Tools d
|
|
|
26
26
|
In general, the code to implement a debugging tool that does nothing and the associated configuration is as follows.
|
|
27
27
|
|
|
28
28
|
``` ts do-nothing.ts
|
|
29
|
-
export
|
|
29
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
30
30
|
name: 'do-nothing',
|
|
31
31
|
setup() {
|
|
32
32
|
return {
|
|
@@ -167,7 +167,7 @@ The Module Tools configuration file - `modern.config.(j|t)s` - is provided in th
|
|
|
167
167
|
By default, the contents of the generated configuration file are as follows.
|
|
168
168
|
|
|
169
169
|
```ts title="modern.config.ts"
|
|
170
|
-
import moduleTools,
|
|
170
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
171
171
|
|
|
172
172
|
export default defineConfig({
|
|
173
173
|
plugins: [moduleTools()],
|
|
@@ -178,7 +178,7 @@ export default defineConfig({
|
|
|
178
178
|
**We recommend using the `defineConfig` function**, but it is not mandatory to use it. So you can also return an object directly in the config file: the
|
|
179
179
|
|
|
180
180
|
``` ts title="modern.config.ts"
|
|
181
|
-
import moduleTools from '@modern-js/module-tools';
|
|
181
|
+
import { moduleTools } from '@modern-js/module-tools';
|
|
182
182
|
|
|
183
183
|
export default {
|
|
184
184
|
plugins: [moduleTools()],
|
|
@@ -9,7 +9,7 @@ sidebar_position: 3
|
|
|
9
9
|
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 specified as follows.
|
|
10
10
|
|
|
11
11
|
```ts title="modern.config.ts"
|
|
12
|
-
import moduleTools,
|
|
12
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
13
13
|
|
|
14
14
|
export default defineConfig({
|
|
15
15
|
plugins: [moduleTools()],
|
|
@@ -58,7 +58,7 @@ For example, if the output product is based on the preset string `"npm-library"`
|
|
|
58
58
|
For example, to achieve the same effect as the preset string ``npm-library-es5"` using the form of a preset function, you can do the following.
|
|
59
59
|
|
|
60
60
|
```ts title="modern.config.ts"
|
|
61
|
-
import moduleTools,
|
|
61
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
62
62
|
|
|
63
63
|
export default defineConfig({
|
|
64
64
|
plugins: [moduleTools()],
|
|
@@ -22,13 +22,13 @@ When we want to test some modules, we can enable the test feature. When this fea
|
|
|
22
22
|
:::tip
|
|
23
23
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
24
24
|
``` ts
|
|
25
|
-
import moduleTools,
|
|
26
|
-
import
|
|
25
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
26
|
+
import { testingPlugin } from '@modern-js/plugin-testing';
|
|
27
27
|
|
|
28
28
|
export default defineConfig({
|
|
29
29
|
plugins: [
|
|
30
30
|
moduleTools(),
|
|
31
|
-
|
|
31
|
+
testingPlugin(),
|
|
32
32
|
],
|
|
33
33
|
});
|
|
34
34
|
```
|
|
@@ -41,8 +41,8 @@ The **Storybook feature** can be enabled when we want to debug a component or a
|
|
|
41
41
|
:::tip
|
|
42
42
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
43
43
|
``` ts
|
|
44
|
-
import moduleTools,
|
|
45
|
-
import storybookPlugin from '@modern-js/plugin-storybook';
|
|
44
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
45
|
+
import { storybookPlugin } from '@modern-js/plugin-storybook';
|
|
46
46
|
|
|
47
47
|
export default defineConfig({
|
|
48
48
|
plugins: [
|
|
@@ -71,8 +71,8 @@ For more information on how to use Tailwind CSS in your module projects, check o
|
|
|
71
71
|
:::tip
|
|
72
72
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
73
73
|
``` ts
|
|
74
|
-
import moduleTools,
|
|
75
|
-
import
|
|
74
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
75
|
+
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss';
|
|
76
76
|
|
|
77
77
|
export default defineConfig({
|
|
78
78
|
plugins: [
|
|
@@ -94,7 +94,7 @@ Also, the Storybook debugging tool will determine if the project needs to use th
|
|
|
94
94
|
:::tip
|
|
95
95
|
After successfully enabling it, you will be prompted to manually add a code similar to the one below to the configuration.
|
|
96
96
|
``` ts
|
|
97
|
-
import moduleTools,
|
|
97
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
98
98
|
import runtime from '@modern-js/runtime/cli';
|
|
99
99
|
|
|
100
100
|
export default defineConfig({
|
|
@@ -54,7 +54,7 @@ npm install -D @modern-js/module-tools typescript
|
|
|
54
54
|
Next, create the `modern.config.(t|j)s` file in the root of the project.
|
|
55
55
|
|
|
56
56
|
``` ts
|
|
57
|
-
import moduleTools,
|
|
57
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
58
58
|
|
|
59
59
|
export default defineConfig({
|
|
60
60
|
plugins: [moduleTools()],
|
|
@@ -11,7 +11,7 @@ In the [[Plugin object]](/plugins/guide/plugin-object) section we know that the
|
|
|
11
11
|
The `setup` function of the plugin will provide an `api` object parameter, and you can call some of the methods provided on this object to get information about the configuration, project context, etc.
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
export
|
|
14
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
15
15
|
name: 'my-plugin',
|
|
16
16
|
|
|
17
17
|
setup(api) {
|
|
@@ -79,7 +79,7 @@ Used to get the executors of Hooks and trigger the execution of a specific Hook.
|
|
|
79
79
|
```ts
|
|
80
80
|
import type { CliPlugin } from '@modern-js/core';
|
|
81
81
|
|
|
82
|
-
export
|
|
82
|
+
export const myPlugin = (): CliPlugin => ({
|
|
83
83
|
name: 'my-plugin',
|
|
84
84
|
|
|
85
85
|
async setup(api) {
|
|
@@ -95,7 +95,7 @@ export default (): CliPlugin => ({
|
|
|
95
95
|
The setup of a CLI plugin can be an asynchronous function that performs asynchronous logic during the initialization process.
|
|
96
96
|
|
|
97
97
|
```ts
|
|
98
|
-
export
|
|
98
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
99
99
|
name: 'my-plugin',
|
|
100
100
|
|
|
101
101
|
async setup(api) {
|
|
@@ -24,7 +24,7 @@ pnpm add @modern-js/plugin-module-babel -D
|
|
|
24
24
|
You can install the plugin with the following command:
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
import moduleTools,
|
|
27
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
28
28
|
import { modulePluginBabel } from '@modern-js/plugin-module-babel';
|
|
29
29
|
|
|
30
30
|
export default defineConfig({
|
|
@@ -42,7 +42,7 @@ See [babel options](https://babeljs.io/docs/options).
|
|
|
42
42
|
Here is an example with `@babel/preset-env` configured
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
|
-
import moduleTools,
|
|
45
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
46
46
|
import { modulePluginBabel } from '@modern-js/plugin-module-babel';
|
|
47
47
|
|
|
48
48
|
export default defineConfig({
|
|
@@ -22,7 +22,7 @@ pnpm add @modern-js/plugin-module-banner -D
|
|
|
22
22
|
You can install the plugin with the following command:
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
import moduleTools,
|
|
25
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
26
26
|
import { modulePluginBanner } from '@modern-js/plugin-module-banner';
|
|
27
27
|
|
|
28
28
|
export default defineConfig({
|
|
@@ -48,7 +48,7 @@ Note: CSS comments do not support the `//comment` syntax. Refer to [【CSS Comme
|
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
50
|
import { modulePluginBanner } from '@modern-js/plugin-module-banner';
|
|
51
|
-
import moduleTools,
|
|
51
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
const copyRight = `/*
|
|
@@ -26,7 +26,7 @@ pnpm add @modern-js/plugin-module-import -D
|
|
|
26
26
|
In Module Tools, you can register plugins in the following way:
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
import moduleTools,
|
|
29
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
30
30
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
31
31
|
|
|
32
32
|
export default defineConfig({
|
|
@@ -64,7 +64,7 @@ The elements of the array are configuration objects for `babel-plugin-import`, w
|
|
|
64
64
|
|
|
65
65
|
```ts
|
|
66
66
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
67
|
-
import moduleTools,
|
|
67
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
68
68
|
|
|
69
69
|
export default defineConfig({
|
|
70
70
|
plugins: [
|
|
@@ -110,7 +110,7 @@ Add the following configuration on the right-hand side:
|
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
112
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
113
|
-
import moduleTools,
|
|
113
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
114
114
|
|
|
115
115
|
export default defineConfig({
|
|
116
116
|
plugins: [
|
|
@@ -159,7 +159,7 @@ The template used here is [handlebars](https://handlebarsjs.com). There are some
|
|
|
159
159
|
|
|
160
160
|
```ts focus=8:8
|
|
161
161
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
162
|
-
import moduleTools,
|
|
162
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
163
163
|
|
|
164
164
|
export default defineConfig({
|
|
165
165
|
plugins: [
|
|
@@ -26,7 +26,7 @@ pnpm add @modern-js/plugin-module-node-polyfill -D
|
|
|
26
26
|
In Module Tools, you can register plugins in the following way:
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
import moduleTools,
|
|
29
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
30
30
|
import { modulePluginNodePolyfill } from '@modern-js/plugin-module-node-polyfill';
|
|
31
31
|
|
|
32
32
|
export default defineConfig({
|
|
@@ -53,7 +53,7 @@ type NodePolyfillOptions = {
|
|
|
53
53
|
Exclude the Node Polyfill to be injected.
|
|
54
54
|
|
|
55
55
|
``` ts focus=7:9
|
|
56
|
-
import moduleTools,
|
|
56
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
57
57
|
import { modulePluginNodePolyfill } from '@modern-js/plugin-module-node-polyfill';
|
|
58
58
|
|
|
59
59
|
export default defineConfig({
|
|
@@ -71,7 +71,7 @@ export default defineConfig({
|
|
|
71
71
|
Override the built-in Node Polyfill.
|
|
72
72
|
|
|
73
73
|
``` ts focus=7:9
|
|
74
|
-
import moduleTools,
|
|
74
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
75
75
|
import { modulePluginNodePolyfill } from '@modern-js/plugin-module-node-polyfill';
|
|
76
76
|
|
|
77
77
|
export default defineConfig({
|
|
@@ -27,7 +27,7 @@ pnpm add @modern-js/plugin-module-polyfill -D
|
|
|
27
27
|
In Module Tools, you can register plugins in the following way:
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
import moduleTools,
|
|
30
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
31
31
|
import { modulePluginPolyfill } from '@modern-js/plugin-module-polyfill';
|
|
32
32
|
|
|
33
33
|
export default defineConfig({
|
|
@@ -55,7 +55,7 @@ See [Babel target](https://babeljs.io/docs/options#targets).
|
|
|
55
55
|
This is a example.
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
|
-
import moduleTools,
|
|
58
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
59
59
|
import { modulePluginPolyfill } from '@modern-js/plugin-module-polyfill';
|
|
60
60
|
|
|
61
61
|
export default defineConfig({
|
|
@@ -454,6 +454,8 @@ js 产物输出的格式,其中 `iife` 和 `umd` 只能在 `buildType` 为 `bund
|
|
|
454
454
|
- 类型: `string[] | Record<string, string>`
|
|
455
455
|
- 默认值: `bundle` 模式下默认为 `['src/index.ts']`,`bundleless` 模式下默认为 `['src']`
|
|
456
456
|
|
|
457
|
+
**数组用法:**
|
|
458
|
+
|
|
457
459
|
```js modern.config.ts
|
|
458
460
|
export default defineConfig({
|
|
459
461
|
buildConfig: {
|
|
@@ -462,11 +464,33 @@ export default defineConfig({
|
|
|
462
464
|
});
|
|
463
465
|
```
|
|
464
466
|
|
|
467
|
+
**对象用法:**
|
|
468
|
+
|
|
469
|
+
当在 bundle 模式下需要修改产物的输出文件名称的时候,可以使用对象形式进行配置。
|
|
470
|
+
|
|
471
|
+
**对象的 Key 是产物的文件名称,Value 是源码的文件路径。**
|
|
472
|
+
|
|
473
|
+
```js modern.config.ts
|
|
474
|
+
export default defineConfig({
|
|
475
|
+
buildConfig: {
|
|
476
|
+
format: 'esm',
|
|
477
|
+
input: {
|
|
478
|
+
'index.esm': './src/index.ts',
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
});
|
|
482
|
+
```
|
|
483
|
+
|
|
465
484
|
## jsx
|
|
466
485
|
|
|
467
|
-
指定
|
|
486
|
+
指定 JSX 的编译方式,默认支持 React17 以上,自动注入 JSX 运行时代码。如果需要支持 React16,则设置 `jsx` 为 `transform`。
|
|
468
487
|
|
|
469
|
-
|
|
488
|
+
> 关于 JSX Transform,可以参考以下链接:
|
|
489
|
+
>
|
|
490
|
+
> - [React Blog](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html)。
|
|
491
|
+
> - [esbuild JSX](https://esbuild.github.io/api/#jsx)
|
|
492
|
+
>
|
|
493
|
+
- 类型: `automatic | transform`
|
|
470
494
|
- 默认值: `automatic`
|
|
471
495
|
|
|
472
496
|
## metafile
|
|
@@ -744,6 +768,22 @@ export default defineConfig({
|
|
|
744
768
|
|
|
745
769
|
详细配置查看 [PostCSS](https://github.com/postcss/postcss#options)。
|
|
746
770
|
|
|
771
|
+
**基础使用:**
|
|
772
|
+
|
|
773
|
+
``` js modern.config.ts
|
|
774
|
+
export default defineConfig({
|
|
775
|
+
buildConfig: {
|
|
776
|
+
style: {
|
|
777
|
+
postcss: {
|
|
778
|
+
plugins: [
|
|
779
|
+
yourPostCSSPlugin,
|
|
780
|
+
],
|
|
781
|
+
},
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
});
|
|
785
|
+
```
|
|
786
|
+
|
|
747
787
|
## style.inject
|
|
748
788
|
|
|
749
789
|
配置打包模式下是否将 CSS 样式插入到 JavaScript 代码中。
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
执行整体构建流程之前触发。
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
export
|
|
25
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
26
26
|
name: 'my-plugin',
|
|
27
27
|
|
|
28
28
|
setup() {
|
|
@@ -61,7 +61,7 @@ type Return = BuildConfig;
|
|
|
61
61
|
根据构建配置,Module Tools 会将整体构建分成多个子构建任务。该 Hook 将会在每一个构建子任务之前触发。
|
|
62
62
|
|
|
63
63
|
```ts
|
|
64
|
-
export
|
|
64
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
65
65
|
name: 'my-plugin',
|
|
66
66
|
|
|
67
67
|
setup() {
|
|
@@ -83,7 +83,7 @@ export default (): CliPlugin<ModuleTools> => ({
|
|
|
83
83
|
每一个构建子任务结束之后触发。
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
|
-
export
|
|
86
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
87
87
|
name: 'my-plugin',
|
|
88
88
|
|
|
89
89
|
setup() {
|
|
@@ -111,7 +111,7 @@ export interface BuildTaskResult {
|
|
|
111
111
|
整体构建流程结束之后触发。
|
|
112
112
|
|
|
113
113
|
```ts
|
|
114
|
-
export
|
|
114
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
115
115
|
name: 'my-plugin',
|
|
116
116
|
|
|
117
117
|
setup() {
|
|
@@ -154,7 +154,7 @@ module-tools 还提供了 `build --platform` 命令来执行特定的构建任
|
|
|
154
154
|
获取在执行 `build --platform` 命令时候需要运行的任务信息。
|
|
155
155
|
|
|
156
156
|
```ts
|
|
157
|
-
export
|
|
157
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
158
158
|
name: 'my-plugin',
|
|
159
159
|
|
|
160
160
|
setup() {
|
|
@@ -190,7 +190,7 @@ export interface RegisterBuildPlatformResult {
|
|
|
190
190
|
当执行 `build --platform` 命令的时候,会触发所有已注册的构建任务。`beforeBuildPlatform` 会在执行整体的构建任务之前触发。
|
|
191
191
|
|
|
192
192
|
```ts
|
|
193
|
-
export
|
|
193
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
194
194
|
name: 'my-plugin',
|
|
195
195
|
|
|
196
196
|
setup() {
|
|
@@ -220,7 +220,7 @@ export interface RegisterBuildPlatformResult {
|
|
|
220
220
|
当执行 `build --platform` 命令的时候,会触发所有已注册的构建任务。`buildPlatform` 会在每个构建任务执行之前触发。
|
|
221
221
|
|
|
222
222
|
```ts
|
|
223
|
-
export
|
|
223
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
224
224
|
name: 'my-plugin',
|
|
225
225
|
|
|
226
226
|
setup() {
|
|
@@ -246,7 +246,7 @@ export interface Options {
|
|
|
246
246
|
当执行 `build --platform` 命令的时候,会触发所有已注册的构建任务。`afterBuildPlatform` 会在整体 platform 构建任务结束后触发。
|
|
247
247
|
|
|
248
248
|
```ts
|
|
249
|
-
export
|
|
249
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
250
250
|
name: 'my-plugin',
|
|
251
251
|
|
|
252
252
|
setup() {
|
|
@@ -294,7 +294,7 @@ export interface BuildPlatformResult {
|
|
|
294
294
|
- 执行调试任务的函数。
|
|
295
295
|
|
|
296
296
|
```ts
|
|
297
|
-
export
|
|
297
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
298
298
|
name: 'my-plugin',
|
|
299
299
|
|
|
300
300
|
setup() {
|
|
@@ -348,7 +348,7 @@ export interface DevToolData {
|
|
|
348
348
|
在收集完所有调试工具元数据后,执行 dev 任务之前触发。
|
|
349
349
|
|
|
350
350
|
```ts
|
|
351
|
-
export
|
|
351
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
352
352
|
name: 'my-plugin',
|
|
353
353
|
|
|
354
354
|
setup() {
|
|
@@ -397,7 +397,7 @@ const question = [
|
|
|
397
397
|
`afterDevMenu` 选择调试列表/菜单选项后触发。
|
|
398
398
|
|
|
399
399
|
```ts
|
|
400
|
-
export
|
|
400
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
401
401
|
name: 'my-plugin',
|
|
402
402
|
|
|
403
403
|
setup() {
|
|
@@ -444,7 +444,7 @@ export interface DevToolData {
|
|
|
444
444
|
执行调试任务之前触发。
|
|
445
445
|
|
|
446
446
|
```ts
|
|
447
|
-
export
|
|
447
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
448
448
|
name: 'my-plugin',
|
|
449
449
|
|
|
450
450
|
setup() {
|
|
@@ -479,7 +479,7 @@ export interface DevToolData {
|
|
|
479
479
|
在中断调试任务进程时触发。
|
|
480
480
|
|
|
481
481
|
```ts
|
|
482
|
-
export
|
|
482
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
483
483
|
name: 'my-plugin',
|
|
484
484
|
|
|
485
485
|
setup() {
|
|
@@ -167,7 +167,7 @@ npm install -g pnpm
|
|
|
167
167
|
默认情况下,生成的配置文件的内容如下:
|
|
168
168
|
|
|
169
169
|
```ts title="modern.config.ts"
|
|
170
|
-
import moduleTools,
|
|
170
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
171
171
|
|
|
172
172
|
export default defineConfig({
|
|
173
173
|
plugins: [moduleTools()],
|
|
@@ -178,7 +178,7 @@ export default defineConfig({
|
|
|
178
178
|
**我们推荐使用 `defineConfig` 函数**,不过并不强制使用它。因此你也可以在配置文件中直接返回一个对象:
|
|
179
179
|
|
|
180
180
|
```ts title="modern.config.ts"
|
|
181
|
-
import moduleTools from '@modern-js/module-tools';
|
|
181
|
+
import { moduleTools } from '@modern-js/module-tools';
|
|
182
182
|
|
|
183
183
|
export default {
|
|
184
184
|
plugins: [moduleTools()],
|
|
@@ -9,7 +9,7 @@ sidebar_position: 3
|
|
|
9
9
|
当在初始化的项目里使用 `modern build` 命令的时候,会根据 Module Tools 默认支持的配置生成相应的产物。默认支持的配置具体如下:
|
|
10
10
|
|
|
11
11
|
```ts title="modern.config.ts"
|
|
12
|
-
import moduleTools,
|
|
12
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
13
13
|
|
|
14
14
|
export default defineConfig({
|
|
15
15
|
plugins: [moduleTools()],
|
|
@@ -58,7 +58,7 @@ export default defineConfig({
|
|
|
58
58
|
例如,如果使用预设函数的形式达到预设字符串 `"npm-library-es5"` 同样的效果,可以按照如下的方式:
|
|
59
59
|
|
|
60
60
|
```ts title="modern.config.ts"
|
|
61
|
-
import moduleTools,
|
|
61
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
62
62
|
|
|
63
63
|
export default defineConfig({
|
|
64
64
|
plugins: [moduleTools()],
|
|
@@ -11,13 +11,13 @@ sidebar_position: 6
|
|
|
11
11
|
想要使用项目的测试功能,需要确保项目中包含依赖:`"@modern-js/plugin-testing"`,以及按照类似下面的内容进行配置:
|
|
12
12
|
|
|
13
13
|
``` ts
|
|
14
|
-
import moduleTools,
|
|
15
|
-
import
|
|
14
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
15
|
+
import { testingPlugin } from '@modern-js/plugin-testing';
|
|
16
16
|
|
|
17
17
|
export default defineConfig({
|
|
18
18
|
plugins: [
|
|
19
19
|
moduleTools(),
|
|
20
|
-
|
|
20
|
+
testingPlugin(),
|
|
21
21
|
],
|
|
22
22
|
});
|
|
23
23
|
```
|
|
@@ -21,13 +21,13 @@ sidebar_position: 4
|
|
|
21
21
|
:::tip
|
|
22
22
|
在成功开启后,会提示需要手动在配置中增加如下类似的代码。
|
|
23
23
|
``` ts
|
|
24
|
-
import moduleTools,
|
|
25
|
-
import
|
|
24
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
25
|
+
import { testingPlugin } from '@modern-js/plugin-testing';
|
|
26
26
|
|
|
27
27
|
export default defineConfig({
|
|
28
28
|
plugins: [
|
|
29
29
|
moduleTools(),
|
|
30
|
-
|
|
30
|
+
testingPlugin(),
|
|
31
31
|
],
|
|
32
32
|
});
|
|
33
33
|
```
|
|
@@ -40,8 +40,8 @@ export default defineConfig({
|
|
|
40
40
|
:::tip
|
|
41
41
|
在成功开启后,会提示需要手动在配置中增加如下类似的代码。
|
|
42
42
|
``` ts
|
|
43
|
-
import moduleTools,
|
|
44
|
-
import storybookPlugin from '@modern-js/plugin-storybook';
|
|
43
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
44
|
+
import { storybookPlugin } from '@modern-js/plugin-storybook';
|
|
45
45
|
|
|
46
46
|
export default defineConfig({
|
|
47
47
|
plugins: [
|
|
@@ -68,8 +68,8 @@ export default defineConfig({
|
|
|
68
68
|
:::tip
|
|
69
69
|
在成功开启后,会提示需要手动在配置中增加如下类似的代码。
|
|
70
70
|
``` ts
|
|
71
|
-
import moduleTools,
|
|
72
|
-
import
|
|
71
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
72
|
+
import { tailwindcssPlugin } from '@modern-js/plugin-tailwindcss';
|
|
73
73
|
|
|
74
74
|
export default defineConfig({
|
|
75
75
|
plugins: [
|
|
@@ -89,7 +89,7 @@ export default defineConfig({
|
|
|
89
89
|
:::tip
|
|
90
90
|
在成功开启后,会提示需要手动在配置中增加如下类似的代码。
|
|
91
91
|
``` ts
|
|
92
|
-
import moduleTools,
|
|
92
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
93
93
|
import runtime from '@modern-js/runtime/cli';
|
|
94
94
|
|
|
95
95
|
export default defineConfig({
|
|
@@ -51,7 +51,7 @@ npm install -D @modern-js/module-tools typescript
|
|
|
51
51
|
接着在项目的根目录下创建 `modern.config.(t|j)s` 文件:
|
|
52
52
|
|
|
53
53
|
```ts
|
|
54
|
-
import moduleTools,
|
|
54
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
55
55
|
|
|
56
56
|
export default defineConfig({
|
|
57
57
|
plugins: [moduleTools()],
|
|
@@ -11,7 +11,7 @@ sidebar_position: 3
|
|
|
11
11
|
插件的 `setup` 函数会提供一个 `api` 对象参数,你可以调用该对象上提供的一些方法来获取到配置、项目上下文等信息。
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
export
|
|
14
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
15
15
|
name: 'my-plugin',
|
|
16
16
|
|
|
17
17
|
setup(api) {
|
|
@@ -79,7 +79,7 @@ interface NormalizedConfig {
|
|
|
79
79
|
```ts
|
|
80
80
|
import type { CliPlugin } from '@modern-js/core';
|
|
81
81
|
|
|
82
|
-
export
|
|
82
|
+
export const myPlugin = (): CliPlugin => ({
|
|
83
83
|
name: 'my-plugin',
|
|
84
84
|
|
|
85
85
|
async setup(api) {
|
|
@@ -95,7 +95,7 @@ export default (): CliPlugin => ({
|
|
|
95
95
|
CLI 插件的 setup 可以是一个异步函数,在初始化过程中执行异步逻辑。
|
|
96
96
|
|
|
97
97
|
```ts
|
|
98
|
-
export
|
|
98
|
+
export const myPlugin = (): CliPlugin<ModuleTools> => ({
|
|
99
99
|
name: 'my-plugin',
|
|
100
100
|
|
|
101
101
|
async setup(api) {
|
|
@@ -24,7 +24,7 @@ pnpm add @modern-js/plugin-module-babel -D
|
|
|
24
24
|
在 Module Tools 中,你可以按照如下方式注册插件:
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
import moduleTools,
|
|
27
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
28
28
|
import { modulePluginBabel } from '@modern-js/plugin-module-babel';
|
|
29
29
|
|
|
30
30
|
export default defineConfig({
|
|
@@ -42,7 +42,7 @@ See [Babel options](https://babeljs.io/docs/options)
|
|
|
42
42
|
下面是一个配置了`@babel/preset-env`的例子:
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
|
-
import moduleTools,
|
|
45
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
46
46
|
import { modulePluginBabel } from '@modern-js/plugin-module-babel';
|
|
47
47
|
|
|
48
48
|
export default defineConfig({
|
|
@@ -22,7 +22,7 @@ pnpm add @modern-js/plugin-module-banner -D
|
|
|
22
22
|
在 Module Tools 中,你可以按照如下方式注册插件:
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
import moduleTools,
|
|
25
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
26
26
|
import { modulePluginBanner } from '@modern-js/plugin-module-banner';
|
|
27
27
|
|
|
28
28
|
export default defineConfig({
|
|
@@ -48,7 +48,7 @@ export default defineConfig({
|
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
50
|
import { modulePluginBanner } from '@modern-js/plugin-module-banner';
|
|
51
|
-
import moduleTools,
|
|
51
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
52
52
|
|
|
53
53
|
const copyRight = `/*
|
|
54
54
|
© Copyright 2020 xxx.com or one of its affiliates.
|
|
@@ -27,7 +27,7 @@ pnpm add @modern-js/plugin-module-import -D
|
|
|
27
27
|
在 Module Tools 中,你可以按照如下方式注册插件:
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
import moduleTools,
|
|
30
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
31
31
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
32
32
|
|
|
33
33
|
export default defineConfig({
|
|
@@ -65,7 +65,7 @@ type Options = {
|
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
67
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
68
|
-
import moduleTools,
|
|
68
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
69
69
|
|
|
70
70
|
export default defineConfig({
|
|
71
71
|
plugins: [
|
|
@@ -111,7 +111,7 @@ import { MyButton as Btn } from 'foo';
|
|
|
111
111
|
|
|
112
112
|
```ts
|
|
113
113
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
114
|
-
import moduleTools,
|
|
114
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
115
115
|
|
|
116
116
|
export default defineConfig({
|
|
117
117
|
plugins: [
|
|
@@ -132,7 +132,7 @@ export default defineConfig({
|
|
|
132
132
|
|
|
133
133
|
```ts focus=8:8
|
|
134
134
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
135
|
-
import moduleTools,
|
|
135
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
136
136
|
|
|
137
137
|
export default defineConfig({
|
|
138
138
|
plugins: [
|
|
@@ -162,7 +162,7 @@ import Btn from 'foo/es/MyButton';
|
|
|
162
162
|
|
|
163
163
|
```ts focus=8:8
|
|
164
164
|
import { modulePluginImport } from '@modern-js/plugin-module-import';
|
|
165
|
-
import moduleTools,
|
|
165
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
166
166
|
|
|
167
167
|
export default defineConfig({
|
|
168
168
|
plugins: [
|
|
@@ -26,7 +26,7 @@ pnpm add @modern-js/plugin-module-node-polyfill -D
|
|
|
26
26
|
在 Module Tools 中,你可以按照如下方式注册插件:
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
|
-
import moduleTools,
|
|
29
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
30
30
|
import { modulePluginNodePolyfill } from '@modern-js/plugin-module-node-polyfill';
|
|
31
31
|
|
|
32
32
|
export default defineConfig({
|
|
@@ -53,7 +53,7 @@ type NodePolyfillOptions = {
|
|
|
53
53
|
排除要注入的 Node Polyfill。
|
|
54
54
|
|
|
55
55
|
``` ts focus=7:9
|
|
56
|
-
import moduleTools,
|
|
56
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
57
57
|
import { modulePluginNodePolyfill } from '@modern-js/plugin-module-node-polyfill';
|
|
58
58
|
|
|
59
59
|
export default defineConfig({
|
|
@@ -71,7 +71,7 @@ export default defineConfig({
|
|
|
71
71
|
覆盖内置的 Node Polyfill。
|
|
72
72
|
|
|
73
73
|
``` ts focus=7:9
|
|
74
|
-
import moduleTools,
|
|
74
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
75
75
|
import { modulePluginNodePolyfill } from '@modern-js/plugin-module-node-polyfill';
|
|
76
76
|
|
|
77
77
|
export default defineConfig({
|
|
@@ -27,7 +27,7 @@ pnpm add @modern-js/plugin-module-polyfill -D
|
|
|
27
27
|
在 Module Tools 中,你可以按照如下方式注册插件:
|
|
28
28
|
|
|
29
29
|
```ts
|
|
30
|
-
import moduleTools,
|
|
30
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
31
31
|
import { modulePluginPolyfill } from '@modern-js/plugin-module-polyfill';
|
|
32
32
|
|
|
33
33
|
export default defineConfig({
|
|
@@ -55,7 +55,7 @@ type options = {
|
|
|
55
55
|
下面是一个例子:
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
|
-
import moduleTools,
|
|
58
|
+
import { moduleTools, defineConfig } from '@modern-js/module-tools';
|
|
59
59
|
import { modulePluginPolyfill } from '@modern-js/plugin-module-polyfill';
|
|
60
60
|
|
|
61
61
|
export default defineConfig({
|
package/modern.config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import docTools,
|
|
2
|
+
import { docTools, defineConfig, NavItem } from '@modern-js/doc-tools';
|
|
3
3
|
import { remarkCodeHike } from '@code-hike/mdx';
|
|
4
4
|
import { pluginAutoSidebar } from '@modern-js/doc-plugin-auto-sidebar';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
"directory": "packages/document/module-doc"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "2.
|
|
12
|
+
"version": "2.25.0",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@code-hike/mdx": "^0.7.4",
|
|
16
16
|
"react": "^18.2.0",
|
|
17
17
|
"react-dom": "^18.2.0",
|
|
18
18
|
"shiki": "^0.11.1",
|
|
19
|
-
"@modern-js/doc-
|
|
20
|
-
"@modern-js/doc-
|
|
19
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.25.0",
|
|
20
|
+
"@modern-js/doc-tools": "2.25.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"dev": "modern dev",
|