@modern-js/module-tools-docs 2.24.1 → 2.25.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 (46) hide show
  1. package/CHANGELOG.md +16 -3
  2. package/docs/en/api/config/build-config.md +185 -29
  3. package/docs/en/api/config/build-preset.mdx +3 -3
  4. package/docs/en/api/config/design-system.md +3 -3
  5. package/docs/en/api/config/dev.md +22 -25
  6. package/docs/en/api/config/plugins.md +50 -5
  7. package/docs/en/api/config/testing.md +3 -3
  8. package/docs/en/api/plugin-api/plugin-hooks.md +13 -13
  9. package/docs/en/guide/advance/build-umd.mdx +1 -1
  10. package/docs/en/guide/advance/in-depth-about-dev-command.md +1 -1
  11. package/docs/en/guide/basic/before-getting-started.md +2 -2
  12. package/docs/en/guide/basic/command-preview.md +2 -2
  13. package/docs/en/guide/basic/modify-output-product.md +18 -6
  14. package/docs/en/guide/basic/use-micro-generator.md +8 -8
  15. package/docs/en/guide/best-practices/components.mdx +3 -3
  16. package/docs/en/guide/intro/getting-started.md +1 -1
  17. package/docs/en/plugins/guide/setup-function.mdx +4 -4
  18. package/docs/en/plugins/official-list/plugin-babel.md +2 -2
  19. package/docs/en/plugins/official-list/plugin-banner.md +3 -3
  20. package/docs/en/plugins/official-list/plugin-import.mdx +34 -25
  21. package/docs/en/plugins/official-list/plugin-node-polyfill.md +3 -3
  22. package/docs/en/plugins/official-list/plugin-polyfill.md +2 -2
  23. package/docs/zh/api/config/build-config.md +190 -33
  24. package/docs/zh/api/config/build-preset.mdx +1 -1
  25. package/docs/zh/api/config/design-system.md +3 -3
  26. package/docs/zh/api/config/dev.md +23 -26
  27. package/docs/zh/api/config/plugins.md +50 -5
  28. package/docs/zh/api/config/testing.md +3 -3
  29. package/docs/zh/api/plugin-api/plugin-hooks.md +13 -13
  30. package/docs/zh/guide/advance/build-umd.mdx +1 -1
  31. package/docs/zh/guide/advance/in-depth-about-dev-command.md +1 -1
  32. package/docs/zh/guide/basic/before-getting-started.md +3 -3
  33. package/docs/zh/guide/basic/command-preview.md +3 -3
  34. package/docs/zh/guide/basic/modify-output-product.md +20 -9
  35. package/docs/zh/guide/basic/test-your-project.mdx +3 -3
  36. package/docs/zh/guide/basic/use-micro-generator.md +8 -8
  37. package/docs/zh/guide/best-practices/components.mdx +3 -3
  38. package/docs/zh/guide/intro/getting-started.md +1 -1
  39. package/docs/zh/plugins/guide/setup-function.mdx +4 -4
  40. package/docs/zh/plugins/official-list/plugin-babel.md +2 -2
  41. package/docs/zh/plugins/official-list/plugin-banner.md +3 -3
  42. package/docs/zh/plugins/official-list/plugin-import.mdx +35 -26
  43. package/docs/zh/plugins/official-list/plugin-node-polyfill.md +3 -3
  44. package/docs/zh/plugins/official-list/plugin-polyfill.md +2 -2
  45. package/modern.config.ts +1 -1
  46. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,11 +1,24 @@
1
1
  # @modern-js/module-tools-docs
2
2
 
3
- ## 2.24.1
3
+ ## 2.25.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - @modern-js/doc-plugin-auto-sidebar@2.24.1
8
- - @modern-js/doc-tools@2.24.1
7
+ - @modern-js/doc-tools@2.25.1
8
+ - @modern-js/doc-plugin-auto-sidebar@2.25.1
9
+
10
+ ## 2.25.0
11
+
12
+ ### Minor Changes
13
+
14
+ - ba6f5a6: docs: update module doc FAQ contents
15
+ docs: 更新 module 文档的 FAQ 内容
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [9aa2c25]
20
+ - @modern-js/doc-tools@2.25.0
21
+ - @modern-js/doc-plugin-auto-sidebar@2.25.0
9
22
 
10
23
  ## 2.24.0
11
24
 
@@ -2,9 +2,20 @@
2
2
  sidebar_position: 1
3
3
  ---
4
4
 
5
- # BuildConfig
5
+ # buildConfig
6
6
 
7
- This section describes all the configuration of Module Tools for building
7
+ `buildConfig` is a configuration option that describes how to compile and generate build artifacts. It contains all the configurations related to the build process.
8
+
9
+ - **Type**: `object | object[]`
10
+ - **Default**: `undefined`
11
+
12
+ :::tip
13
+ Before start using `buildConfig`, please read the following documentation to understand its purpose:
14
+
15
+ - [Modifying Output Artifacts](/guide/basic/modify-output-product.html)
16
+ - [In-Depth Understanding of the Build Process](/guide/advance/in-depth-about-build.html)
17
+
18
+ :::
8
19
 
9
20
  ## alias
10
21
 
@@ -110,7 +121,7 @@ At this point, all static resources will be prefixed with `https://xxx/`
110
121
 
111
122
  Packaged to handle svg as a React component, options reference [svgr](https://react-svgr.com/docs/options/), plus support for two configuration items `include` and `exclude` to match the svg file to be handled
112
123
 
113
- - **Type**: `boolean | Object`
124
+ - **Type**: `boolean | object`
114
125
  - **Default**: `false`
115
126
 
116
127
  When svgr feature is enabled, you can use svg as a component using the default export.
@@ -160,7 +171,7 @@ Set unmatched svg files
160
171
 
161
172
  Automatically externalize project dependencies and peerDependencies and not package them into the final bundle
162
173
 
163
- - **Type**: `boolean | Object`
174
+ - **Type**: `boolean | object`
164
175
  - **Default**: `true`
165
176
 
166
177
  When we want to turn off the default handling behavior for third-party dependencies, we can do so by:
@@ -212,7 +223,7 @@ The build type, `bundle` will package your code, `bundleless` will only do the c
212
223
 
213
224
  Copies the specified file or directory into the build output directory
214
225
 
215
- - **Type**: `Array`
226
+ - **Type**: `object[]`
216
227
  - **Default**: `[]`
217
228
 
218
229
  ```js
@@ -295,7 +306,7 @@ The use of SWC Transform can reduce the impact of auxiliary functions on the vol
295
306
 
296
307
  The dts file generates the relevant configuration, by default it generates.
297
308
 
298
- - **Type**: `false | Object`
309
+ - **Type**: `false | object`
299
310
  - **Default**:
300
311
 
301
312
  ```js
@@ -438,23 +449,106 @@ export var yourCode = function () {
438
449
 
439
450
  Configure external dependencies that will not be packaged into the final bundle
440
451
 
441
- - **Type**: `(string | RegExp)[]`
452
+ - **Type**:
453
+
454
+ ```ts
455
+ type External = (string | RegExp)[];
456
+ ```
457
+
442
458
  - **Default**: `[]`
459
+ - **Build Type**: `Only supported for buildType: 'bundle'`
460
+ - **Example**:
461
+
462
+ ```js modern.config.ts
463
+ export default defineConfig({
464
+ buildConfig: {
465
+ // do not bundle React
466
+ externals: ['react'],
467
+ },
468
+ });
469
+ ```
443
470
 
444
471
  ## format
445
472
 
446
- The format of the js product output, where `iife` and `umd` can only take effect when `buildType` is `bundle`
473
+ Used to set the output format of JavaScript files. The options `iife` and `umd` only take effect when `buildType` is `bundle`.
447
474
 
448
475
  - **Type**: `'esm' | 'cjs' | 'iife' | 'umd'`
449
476
  - **Default**: `cjs`
450
477
 
478
+ ### format: 'esm'
479
+
480
+ `esm` stands for "ECMAScript module" and requires the runtime environment to support import and export syntax.
481
+
482
+ - **Example**:
483
+
484
+ ```js modern.config.ts
485
+ export default defineConfig({
486
+ buildConfig: {
487
+ format: 'esm',
488
+ },
489
+ });
490
+ ```
491
+
492
+ ### format: 'cjs'
493
+
494
+ `cjs` stands for "CommonJS" and requires the runtime environment to support exports, require, and module syntax. This format is commonly used in Node.js environments.
495
+
496
+ - **Example**:
497
+
498
+ ```js modern.config.ts
499
+ export default defineConfig({
500
+ buildConfig: {
501
+ format: 'cjs',
502
+ },
503
+ });
504
+ ```
505
+
506
+ ### format: 'iife'
507
+
508
+ `iife` stands for "immediately-invoked function expression" and wraps the code in a function expression to ensure that any variables in the code do not accidentally conflict with variables in the global scope. This format is commonly used in browser environments.
509
+
510
+ - **Example**:
511
+
512
+ ```js modern.config.ts
513
+ export default defineConfig({
514
+ buildConfig: {
515
+ format: 'iife',
516
+ },
517
+ });
518
+ ```
519
+
520
+ ### format: 'umd'
521
+
522
+ `umd` stands for "Universal Module Definition" and is used to run modules in different environments such as browsers and Node.js. Modules in UMD format can be used in various environments, either as global variables or loaded as modules using module loaders like RequireJS.
523
+
524
+ - **Example**:
525
+
526
+ ```js modern.config.ts
527
+ export default defineConfig({
528
+ buildConfig: {
529
+ format: 'umd',
530
+ },
531
+ });
532
+ ```
533
+
451
534
  ## input
452
535
 
453
536
  Specify the entry file for the build, in the form of an array that can specify the directory
454
537
 
455
- - **Type**: `string[] | Record<string, string>`
538
+ - **Type**:
539
+
540
+ ```ts
541
+ type Input =
542
+ | string[];
543
+ | {
544
+ [name: string]: string;
545
+ }
546
+ ```
547
+
456
548
  - **Default**: `['src/index.ts']` in `bundle` mode, `['src']` in `bundleless` mode
457
549
 
550
+ **Array usage:**
551
+
458
552
  ```js modern.config.ts
459
553
  export default {
460
554
  buildConfig: {
@@ -463,25 +557,73 @@ export default {
463
557
  };
464
558
  ```
465
559
 
560
+ **Object usage:**
561
+
562
+ When you need to modify the output file name in bundle mode, you can use an object configuration.
563
+
564
+ **The key of the object is the file name of the output, and the value is the file path of the source code.**
565
+
566
+ ```js modern.config.ts
567
+ export default defineConfig({
568
+ buildConfig: {
569
+ format: 'esm',
570
+ input: {
571
+ 'index.esm': './src/index.ts',
572
+ },
573
+ },
574
+ });
575
+ ```
576
+
466
577
  ## jsx
467
578
 
468
- Specify the compilation method of jsx, default support React17, automatically inject jsx runtime code
579
+ Specify the compilation method for JSX, which by default supports React 17 and higher versions and automatically injects JSX runtime code.
469
580
 
470
- - **Type**: `automatic | classic`
581
+ - **Type**: `automatic | transform`
471
582
  - **Default**: `automatic`
472
583
 
584
+ If you need to support React 16, you can set `jsx` to `transform`:
585
+
586
+ ```js modern.config.ts
587
+ export default defineConfig({
588
+ buildConfig: {
589
+ jsx: 'transform',
590
+ },
591
+ });
592
+ ```
593
+
594
+ :::tip
595
+ For more information about JSX Transform, you can refer to the following links:
596
+
597
+ - [React Blog - Introducing the New JSX Transform](https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html).
598
+ - [esbuild - JSX](https://esbuild.github.io/api/#jsx).
599
+ :::
600
+
473
601
  ## metafile
474
602
 
475
- esbuild to produce some metadata about the build in JSON format, which can be visualized by tools such as [bundle-buddy](https://bundle-buddy.com/esbuild)
603
+ This option is used for build analysis. When enabled, esbuild will generate metadata about the build in JSON format.
476
604
 
477
605
  - **Type**: `boolean`
478
606
  - **Default**: `false`
607
+ - **Build Type**: `Only supported for buildType: 'bundle'`
608
+
609
+ To enable `metafile` generation:
610
+
611
+ ```js modern.config.ts
612
+ export default defineConfig({
613
+ buildConfig: {
614
+ buildType: 'bundle',
615
+ metafile: true,
616
+ },
617
+ });
618
+ ```
619
+
620
+ After executing the build, a `metafile-[xxx].json` file will be generated in the output directory. You can use tools like [esbuild analyze](https://esbuild.github.io/analyze/) and [bundle-buddy](https://bundle-buddy.com/esbuild) for visual analysis.
479
621
 
480
622
  ## minify
481
623
 
482
624
  Use esbuild or terser to compress code, also pass [terserOptions](https://github.com/terser/terser#minify-options)
483
625
 
484
- - **Type**: `'terser' | 'esbuild' | false | Object`
626
+ - **Type**: `'terser' | 'esbuild' | false | object`
485
627
  - **Default**: `false`
486
628
 
487
629
  ```js modern.config.ts
@@ -592,8 +734,8 @@ Whether to generate sourceMap or not
592
734
 
593
735
  Sets the format of the source code. By default, the source code will be treated as EsModule. When the source code is using CommonJS, you need to set `commonjs`.
594
736
 
595
- - **Type**: `commonjs` | `module`
596
- - **Default**: `module`
737
+ - **Type**: `'commonjs' | 'module'`
738
+ - **Default**: `'module'`
597
739
 
598
740
  ## splitting
599
741
 
@@ -614,7 +756,7 @@ less-related configuration
614
756
 
615
757
  Refer to [less](https://less.bootcss.com/usage/#less-options) for detailed configuration
616
758
 
617
- - **Type**: `Object`
759
+ - **Type**: `object`
618
760
  - **Default**: `{ javascriptEnabled: true }`
619
761
 
620
762
  ## style.less.additionalData
@@ -638,12 +780,12 @@ export default {
638
780
 
639
781
  ## style.less.implementation
640
782
 
641
- Configure the implementation library used by `Less`, if not specified, the built-in version used is `4.1.3`
783
+ Configure the implementation library used by `Less`, if not specified, the built-in version used is `4.1.3`.
642
784
 
643
- - **Type**: `string | Object`
785
+ - **Type**: `string | object`
644
786
  - **Default**: `undefined`
645
787
 
646
- Specify the implementation library for `Less` when the `Object` type is specified
788
+ Specify the implementation library for `Less` when the `object` type is specified.
647
789
 
648
790
  ```js modern.config.ts
649
791
  export default {
@@ -677,9 +819,9 @@ sass-related configuration.
677
819
 
678
820
  ## style.sass.sassOptions
679
821
 
680
- Refer to [node-sass](https://github.com/sass/node-sass#options) for detailed configuration
822
+ Refer to [node-sass](https://github.com/sass/node-sass#options) for detailed configuration.
681
823
 
682
- - **Type**: `Object`
824
+ - **Type**: `object`
683
825
  - **Default**: `{}`
684
826
 
685
827
  ## style.sass.additionalData
@@ -704,12 +846,12 @@ export default {
704
846
 
705
847
  ## style.sass.implementation
706
848
 
707
- Configure the implementation library used by `Sass`, the built-in version used is `1.5.4` if not specified
849
+ Configure the implementation library used by `Sass`, the built-in version used is `1.5.4` if not specified.
708
850
 
709
- - **Type**: `string | Object`
851
+ - **Type**: `string | object`
710
852
  - **Default**: `undefined`
711
853
 
712
- Specify the implementation library for `Sass` when the `Object` type is specified
854
+ Specify the implementation library for `Sass` when the `object` type is specified.
713
855
 
714
856
  ```js modern.config.ts
715
857
  export default {
@@ -744,6 +886,20 @@ export default {
744
886
 
745
887
  See [PostCSS](https://github.com/postcss/postcss#options) for detailed configuration
746
888
 
889
+ **Basic usage:**
890
+
891
+ ```js modern.config.ts
892
+ export default defineConfig({
893
+ buildConfig: {
894
+ style: {
895
+ postcss: {
896
+ plugins: [yourPostCSSPlugin],
897
+ },
898
+ },
899
+ },
900
+ });
901
+ ```
902
+
747
903
  ## style.inject
748
904
 
749
905
  Configure whether to insert CSS styles into JavaScript code in bundle mode.
@@ -807,7 +963,7 @@ Enable CSS Modules automatically based on the filename.
807
963
 
808
964
  CSS Modules configuration
809
965
 
810
- - **Type**: `Object`
966
+ - **Type**: `object`
811
967
  - **Default**: `{}`
812
968
 
813
969
  A common configuration is `localsConvention`, which changes the class name generation rules for css modules
@@ -840,7 +996,7 @@ For detailed configuration see [postcss-modules](https://github.com/madyankin/po
840
996
 
841
997
  tailwindcss related configuration
842
998
 
843
- - **Type**: `Object | Function`
999
+ - **Type**: `object | Function`
844
1000
  - **Default**: `see configuration details below`
845
1001
 
846
1002
  <details>
@@ -861,7 +1017,7 @@ const tailwind = {
861
1017
  };
862
1018
  ```
863
1019
 
864
- When the value is of type `Object`, it is merged with the default configuration via `Object.assign`.
1020
+ When the value is of type `object`, it is merged with the default configuration via `Object.assign`.
865
1021
 
866
1022
  When the value is of type `Function`, the object returned by the function is merged with the default configuration via `Object.assign`.
867
1023
 
@@ -906,7 +1062,7 @@ export default defineConfig({
906
1062
 
907
1063
  Using [SWC](https://swc.rs/) provides the same ability and configuration as [`babel-plugin-import`](https://github.com/umijs/babel-plugin-import).
908
1064
 
909
- - **Type**: `Array`
1065
+ - **Type**: `object[]`
910
1066
  - **Default**: `[]`
911
1067
 
912
1068
  The elements of the array are configuration objects for `babel-plugin-import`, which can be referred to [options](https://github.com/umijs/babel-plugin-import#options)。
@@ -955,7 +1111,7 @@ At this point, `react` and `react-dom` will be seen as global variables imported
955
1111
 
956
1112
  Specifies the module name of the umd product
957
1113
 
958
- - **Type**: `string` | `Function`
1114
+ - **Type**: `string | Function`
959
1115
  - **Default**: `name => name`
960
1116
 
961
1117
  ```js
@@ -2,12 +2,12 @@
2
2
  sidebar_position: 2
3
3
  ---
4
4
 
5
- # BuildPreset
5
+ # buildPreset
6
6
 
7
7
  A build preset string or preset function. Provides out-of-the-box build configuration
8
8
 
9
- - Type: `string | Function`
10
- - Default: `undefined`
9
+ - **Type**: `string | Function`
10
+ - **Default**: `undefined`
11
11
 
12
12
  ## string
13
13
 
@@ -2,15 +2,15 @@
2
2
  sidebar_position: 3
3
3
  ---
4
4
 
5
- # DesignSystem
5
+ # designSystem
6
6
 
7
- This chapter describes the configuration related to designSystem
7
+ This chapter describes the configuration related to designSystem.
8
8
 
9
9
  :::tip
10
10
  The Tailwind CSS feature needs to be enabled first via `pnpm run new`.
11
11
  :::
12
12
 
13
- - Type: `Object`
13
+ - Type: `object`
14
14
  - Default: `see configuration details below`.
15
15
 
16
16
  <details>
@@ -2,16 +2,18 @@
2
2
  sidebar_position: 3
3
3
  ---
4
4
 
5
- # Dev Config
5
+ # dev
6
6
 
7
7
  This section describes all configuration of Module Tools related to debugging tools.
8
8
 
9
- ``` ts
9
+ ```ts
10
10
  export default {
11
11
  dev: {
12
- storybook: {/* Storybook Config */},
12
+ storybook: {
13
+ /* Storybook Config */
14
+ },
13
15
  },
14
- }
16
+ };
15
17
  ```
16
18
 
17
19
  ## storybook
@@ -21,36 +23,34 @@ export default {
21
23
  - Turn on Storybook debugging or install the `@modern-js/plugin-storybook` plugin.
22
24
  - Register the `@modern-js/plugin-storybook` plugin。
23
25
 
24
- > For more information on how to enable Storybook debugging, please refer to:[Storybook](guide/basic/use-micro-generator#storybook)
25
-
26
-
26
+ > For more information on how to enable Storybook debugging, please refer to:["Storybook"](guide/basic/use-micro-generator#storybook)
27
27
 
28
28
  ### storybook.webpack
29
29
 
30
- - **Type**: `Object` | `Function` | `undefined`
31
-
30
+ - **Type**: `object | Function | undefined`
32
31
  - **Default**: `undefined`
33
32
 
34
- ``` ts
33
+ ```ts
35
34
  export default {
36
35
  dev: {
37
36
  storybook: {
38
37
  webpack(config) {
39
38
  return config;
40
39
  },
41
- }
42
- }
43
- }
40
+ },
41
+ },
42
+ };
44
43
  ```
45
44
 
46
- You can modify the webpack configuration of the Storybook Preview-iframe via `dev.storybook.webpack`. The usage can be found in the [`tools.webpack`](https://modernjs.dev/builder/api/config-tools.html#tools.webpack) configuration of Modern.js Builder.
45
+ You can modify the webpack configuration of the Storybook Preview-iframe via `dev.storybook.webpack`. The usage can be found in the [`tools.webpack`](https://modernjs.dev/builder/en/api/config-tools.html#toolswebpack) configuration of Modern.js Builder.
47
46
 
48
47
  ![Storybook](https://storybook.js.org/71522ac365feaf3338d7c242e53378f6/manager-preview.png)
49
48
 
50
- :::tip
49
+ #### Configure Manager App
50
+
51
51
  For the webpack configuration of the Storybook Manager app section, you can configure it by adding the `./config/storybook/main.js` file to configure it.
52
52
 
53
- ``` js
53
+ ```js
54
54
  // ./config/storybook/main.js
55
55
 
56
56
  module.exports = {
@@ -61,25 +61,22 @@ module.exports = {
61
61
  },
62
62
  };
63
63
  ```
64
- :::
65
64
 
66
65
  ### storybook.webpackChain
67
66
 
68
- - **Type**: `Function` | `undefined`
69
-
67
+ - **Type**: `Function | undefined`
70
68
  - **Default**: `undefined`
71
69
 
72
- ``` ts
70
+ ```ts
73
71
  export default {
74
72
  dev: {
75
73
  storybook: {
76
74
  webpackChain(chain) {
77
75
  return chain;
78
76
  },
79
- }
80
- }
81
- }
77
+ },
78
+ },
79
+ };
82
80
  ```
83
81
 
84
- You can modify the webpack configuration of the Storybook Preview-iframe via `dev.storybook.webpackChain`. You can refer to Modern.js Builder's [`tools.webpackChain`](https://modernjs.dev/builder/api/config-tools.html#tools.webpackchain) configuration for how to use it.
85
-
82
+ You can modify the webpack configuration of the Storybook Preview-iframe via `dev.storybook.webpackChain`. You can refer to Modern.js Builder's [`tools.webpackChain`](https://modernjs.dev/builder/en/api/config-tools.html#toolswebpackchain) configuration for how to use it.
@@ -2,17 +2,62 @@
2
2
  sidebar_position: 4
3
3
  ---
4
4
 
5
- # Plugins
5
+ # plugins
6
6
 
7
7
  This chapter describes the configuration of the registered Module Tools plugin.
8
8
 
9
- - Type: `Array<ModuleToolsPlugin>`
9
+ - **Type**: `ModuleToolsPlugin[]`
10
+ - **Default**: `undefined`
11
+
12
+ ## Plugin Execution Order
13
+
14
+ By default, custom plugins are executed in the order specified in the `plugins` array. The execution of built-in plugins provided by Module Tools happens before the execution of custom plugins.
15
+
16
+ When plugins use fields that control the execution order, such as `pre` and `post`, the execution order is adjusted based on the declared fields. For more information, please refer to the [Relationship Between Plugins](https://modernjs.dev/en/guides/topic-detail/framework-plugin/relationship) guide.
17
+
18
+ ## Developing Plugins
19
+
20
+ To learn how to write plugins, please refer to the [Plugin Writing Guide](/plugins/guide/getting-started).
21
+
22
+ ## Example
23
+
24
+ ### Using Plugins from npm
25
+
26
+ To use plugins from npm, you need to install them using a package manager and import them in your configuration file.
27
+
28
+ ```js modern.config.ts
29
+ import { myPlugin } from 'my-plugin';
30
+
31
+ export default defineConfig({
32
+ plugins: [myPlugin()],
33
+ });
34
+ ```
35
+
36
+ #### Using Local Plugins
37
+
38
+ To use plugins from a local code repository, you can directly import them using a relative path.
10
39
 
11
40
  ```js modern.config.ts
12
- import { examplePlugin } from '. /plugins/example';
41
+ import { myPlugin } from './plugins/myPlugin';
42
+
13
43
  export default defineConfig({
14
- plugins: [examplePlugin()],
44
+ plugins: [myPlugin()],
15
45
  });
16
46
  ```
17
47
 
18
- For more information on how to write plugins, check out the [[Plugin Writing Guide]](/en/plugins/guide/getting-started).
48
+ ### Plugin Configuration
49
+
50
+ If a plugin provides custom configuration options, you can pass the configuration through the plugin function's parameters.
51
+
52
+ ```js modern.config.ts
53
+ import { myPlugin } from 'my-plugin';
54
+
55
+ export default defineConfig({
56
+ plugins: [
57
+ myPlugin({
58
+ foo: 1,
59
+ bar: 2,
60
+ }),
61
+ ],
62
+ });
63
+ ```
@@ -2,7 +2,7 @@
2
2
  sidebar_position: 5
3
3
  ---
4
4
 
5
- # Testing
5
+ # testing
6
6
 
7
7
  This chapter describes the test-related configuration
8
8
 
@@ -12,10 +12,10 @@ You need to enable the unit testing feature with `pnpm run new` first.
12
12
 
13
13
  ## jest
14
14
 
15
- - Type: `Object | Function`
15
+ - Type: `object | Function`
16
16
  - Default: `{}`
17
17
 
18
- The configuration corresponding to [Jest](https://jestjs.io/docs/configuration), when of type `Object`, can be configured with all the underlying configurations supported by Jest .
18
+ The configuration corresponding to [Jest](https://jestjs.io/docs/configuration), when of type `object`, can be configured with all the underlying configurations supported by Jest .
19
19
 
20
20
  ```js modern.config.ts
21
21
  import { defineConfig } from '@modern-js/module-tools';