@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
@@ -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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin<ModuleTools> => ({
480
+ export const myPlugin = (): CliPlugin<ModuleTools> => ({
481
481
  name: 'my-plugin',
482
482
 
483
483
  setup() {
@@ -22,7 +22,7 @@ export default defineConfig({
22
22
 
23
23
  ## Third-party dependency handling for umd products
24
24
 
25
- In the [[How to handle third-party dependencies]](/en/guide/advance/external-dependency) chapter, we know that we can control whether or not the project packages third-party dependencies via the [`autoExternals`](/en/api/config/build-config#autoexternal) and [`externals`](/en/api/config/build-config#externals) APIs.
25
+ In the ["How to handle third-party dependencies"](/en/guide/advance/external-dependency) chapter, we know that we can control whether or not the project packages third-party dependencies via the [`autoExternals`](/en/api/config/build-config#autoexternal) and [`externals`](/en/api/config/build-config#externals) APIs.
26
26
  So when building umd products, we can also use it like this:
27
27
 
28
28
  <CH.Spotlight>
@@ -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 default (): CliPlugin<ModuleTools> => ({
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, { defineConfig } from '@modern-js/module-tools';
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()],
@@ -2,9 +2,9 @@
2
2
  sidebar_position: 2
3
3
  ---
4
4
 
5
- # Command Preview
5
+ # CLI Commands
6
6
 
7
- Commands available for module engineering projects.
7
+ CLI Commands available for Module Tools projects are as follows:
8
8
 
9
9
  ## `modern build`
10
10
 
@@ -6,13 +6,17 @@ sidebar_position: 3
6
6
 
7
7
  ## Default output products
8
8
 
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.
9
+ When you use the `modern build` command in an initialized project, Module Tools will generate corresponding build products based on the current configuration.
10
+
11
+ The default configuration is as follows:
10
12
 
11
13
  ```ts title="modern.config.ts"
12
- import moduleTools, { defineConfig } from '@modern-js/module-tools';
14
+ import { moduleTools, defineConfig } from '@modern-js/module-tools';
13
15
 
14
16
  export default defineConfig({
17
+ // Register the CLI tool of Module Tools
15
18
  plugins: [moduleTools()],
19
+ // Specify the build preset configuration
16
20
  buildPreset: 'npm-library',
17
21
  });
18
22
  ```
@@ -58,7 +62,7 @@ For example, if the output product is based on the preset string `"npm-library"`
58
62
  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
63
 
60
64
  ```ts title="modern.config.ts"
61
- import moduleTools, { defineConfig } from '@modern-js/module-tools';
65
+ import { moduleTools, defineConfig } from '@modern-js/module-tools';
62
66
 
63
67
  export default defineConfig({
64
68
  plugins: [moduleTools()],
@@ -70,11 +74,19 @@ export default defineConfig({
70
74
  });
71
75
  ```
72
76
 
73
- In the above code implementation, `preset.NPM_LIBRARY` corresponds to the preset string `"npm-library"`, which represents the equivalent of `"npm-library"` for multiple sets of build-related configurations. We traverse the `NPM_LIBRARY` array, which contains multiple `buildConfig` objects, using the `map` method. We made a shallow copy of the original `buildConfig` object and modified the value of the `target` after the shallow copy, specifying it as `es5`.
77
+ In the above code implementation, `preset.NPM_LIBRARY` corresponds to the preset string `"npm-library"`, representing multiple build-related configurations equivalent to `"npm-library"`.
78
+
79
+ We use the `map` method to iterate over the `NPM_LIBRARY` array, which contains multiple `buildConfig` objects. We perform a shallow copy of the original `buildConfig` object and modify the value of the `target` property in the shallow copy to be `es5`.
74
80
 
81
+ If you want to know the specific contents included in `preset.NPM_LIBRARY`, you can refer to the [BuildPreset API](/api/config/build-preset).
82
+
83
+ In addition, under the `preset` object, it not only includes `NPM_LIBRARY`, but also other similar constants.
75
84
 
76
85
  > NPM_LIBRARY`, you can check it with [BuildPreset API](/api/config/build-preset). The`preset`object contains not only`NPM_LIBRARY`, but also other similar constants.
77
- > We can not only use `preset.NPM_LIBRARY` to get the build configuration corresponding to `"npm-library"`, but also `preset['npm-library']` in this way.
86
+
87
+ :::tip
88
+ We can not only use `preset.NPM_LIBRARY`to get the build configuration corresponding to`"npm-library"`, but also `preset['npm-library']` in this way.
89
+ :::
78
90
 
79
91
  So what is the `buildConfig` object here? What is the basis for the build product feature mentioned before?
80
92
 
@@ -82,7 +94,7 @@ Let's explain next.
82
94
 
83
95
  ## Build configuration (object)
84
96
 
85
- **`buildConfig` is a configuration object that describes how to compile and generate build products**. What was mentioned at the beginning about "_features of build products_" are actually properties supported by `buildConfig`. The currently supported properties cover the needs of most module type projects when building products. `buildConfig` not only contains some properties that products have, but also contains some features needed to build products. The following is a brief list from a classification point of view.
97
+ **`buildConfig` is a configuration option that describes how to compile and generate build products**. What was mentioned at the beginning about "_features of build products_" are actually properties supported by `buildConfig`. The currently supported properties cover the needs of most module type projects when building products. `buildConfig` not only contains some properties that products have, but also contains some features needed to build products. The following is a brief list from a classification point of view.
86
98
 
87
99
  **The basic attributes of a build product include:**
88
100
 
@@ -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, { defineConfig } from '@modern-js/module-tools';
26
- import testPlugin from '@modern-js/plugin-testing';
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
- testPlugin(),
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, { defineConfig } from '@modern-js/module-tools';
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, { defineConfig } from '@modern-js/module-tools';
75
- import tailwindPlugin from '@modern-js/plugin-tailwindcss';
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, { defineConfig } from '@modern-js/module-tools';
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({
@@ -605,7 +605,7 @@ When adding styles using HTML class names, by default Tailwind will not only add
605
605
 
606
606
  For the following code, there is a big difference between the bundle and bundleless modes of building products.
607
607
 
608
- > The so-called bundle and bundleless can be found in [[Bundle and Bundleless]](/en/guide/advance/in-depth-about-build#bundle- and-bundleless)
608
+ > The so-called bundle and bundleless can be found in ["Bundle and Bundleless"](/en/guide/advance/in-depth-about-build#bundle- and-bundleless)
609
609
 
610
610
  ```tsx ./src/index.tsx
611
611
  import 'tailwindcss/utilities.css';
@@ -782,8 +782,8 @@ If you have special needs for the build product directory structure, you can use
782
782
 
783
783
  ## Testing components
784
784
 
785
- For more information on how to test components, please refer to [[Test project]](/en/guide/basic/test-your-project).
785
+ For more information on how to test components, please refer to ["Test project"](/en/guide/basic/test-your-project).
786
786
 
787
787
  ## Releasing components
788
788
 
789
- It is recommended to use module project to provide version publishing function, you can refer to [[Versioning and publishing]](/en/guide/basic/publish-your-project).
789
+ It is recommended to use module project to provide version publishing function, you can refer to ["Versioning and publishing"](/en/guide/basic/publish-your-project).
@@ -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, { defineConfig } from '@modern-js/module-tools';
57
+ import { moduleTools, defineConfig } from '@modern-js/module-tools';
58
58
 
59
59
  export default defineConfig({
60
60
  plugins: [moduleTools()],
@@ -4,14 +4,14 @@ sidebar_position: 3
4
4
 
5
5
  # Setup function
6
6
 
7
- In the [[Plugin object]](/plugins/guide/plugin-object) section we know that the plug-in object contains a `setup` function that not only contains an `api` object parameter, but also returns a Hooks object.
7
+ In the ["Plugin object"](/plugins/guide/plugin-object) section we know that the plug-in object contains a `setup` function that not only contains an `api` object parameter, but also returns a Hooks object.
8
8
 
9
9
  ## Plugin API objects
10
10
 
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 default (): CliPlugin<ModuleTools> => ({
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 default (): CliPlugin => ({
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 default (): CliPlugin<ModuleTools> => ({
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, { defineConfig } from '@modern-js/module-tools';
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, { defineConfig } from '@modern-js/module-tools';
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, { defineConfig } from '@modern-js/module-tools';
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({
@@ -39,7 +39,7 @@ export default defineConfig({
39
39
  ```
40
40
 
41
41
  :::tip
42
- Note: CSS comments do not support the `//comment` syntax. Refer to [CSS Comments](https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)
42
+ Note: CSS comments do not support the `//comment` syntax. Refer to ["CSS Comments"](https://developer.mozilla.org/en-US/docs/Web/CSS/Comments)
43
43
  :::
44
44
 
45
45
  ## Example
@@ -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, { defineConfig } from '@modern-js/module-tools';
51
+ import { moduleTools, defineConfig } from '@modern-js/module-tools';
52
52
 
53
53
 
54
54
  const copyRight = `/*
@@ -3,7 +3,7 @@
3
3
  Using [SWC](https://swc.rs/) provides the same ability and configuration as [`babel-plugin-import`](https://github.com/umijs/babel-plugin-import).
4
4
 
5
5
  :::tip
6
- Since @modern-js/module-tools version >= 2.16.0, this plugin functionality is built into module-tools and is provided by [`transformImport`](api/config/build-config.html#transformimport).
6
+ Since `@modern-js/module-tools` version >= v2.16.0, this plugin functionality is built into Module Tools and is provided by [`transformImport`](api/config/build-config.html#transformimport).
7
7
  :::
8
8
 
9
9
  ## Quick Start
@@ -26,17 +26,19 @@ 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, { defineConfig } from '@modern-js/module-tools';
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({
33
33
  plugins: [
34
34
  moduleTools(),
35
35
  modulePluginImport({
36
- pluginImport: [{
37
- libraryName: 'antd',
38
- style: true,
39
- }],
36
+ pluginImport: [
37
+ {
38
+ libraryName: 'antd',
39
+ style: true,
40
+ },
41
+ ],
40
42
  }),
41
43
  ],
42
44
  });
@@ -46,17 +48,17 @@ This way we can use the ability of automatic import in Module Tools.
46
48
 
47
49
  ## Configurations
48
50
 
49
- * **Type**:
51
+ - **Type**:
50
52
 
51
53
  ```ts
52
54
  type Options = {
53
55
  pluginImport?: ImportItem[];
54
- }
56
+ };
55
57
  ```
56
58
 
57
59
  ### pluginImport
58
60
 
59
- * **Type**: `Array`
61
+ - **Type**: `object[]`
60
62
 
61
63
  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)。
62
64
 
@@ -64,7 +66,7 @@ The elements of the array are configuration objects for `babel-plugin-import`, w
64
66
 
65
67
  ```ts
66
68
  import { modulePluginImport } from '@modern-js/plugin-module-import';
67
- import moduleTools, { defineConfig } from '@modern-js/module-tools';
69
+ import { moduleTools, defineConfig } from '@modern-js/module-tools';
68
70
 
69
71
  export default defineConfig({
70
72
  plugins: [
@@ -75,7 +77,7 @@ export default defineConfig({
75
77
  {
76
78
  libraryName: 'foo',
77
79
  style: true,
78
- }
80
+ },
79
81
  ],
80
82
  }),
81
83
  ],
@@ -110,16 +112,18 @@ Add the following configuration on the right-hand side:
110
112
 
111
113
  ```ts
112
114
  import { modulePluginImport } from '@modern-js/plugin-module-import';
113
- import moduleTools, { defineConfig } from '@modern-js/module-tools';
115
+ import { moduleTools, defineConfig } from '@modern-js/module-tools';
114
116
 
115
117
  export default defineConfig({
116
118
  plugins: [
117
119
  moduleTools(),
118
120
  modulePluginImport({
119
- pluginImport: [{
120
- libraryName: 'foo',
121
- customName: 'foo/es/{{ member }}'
122
- }],
121
+ pluginImport: [
122
+ {
123
+ libraryName: 'foo',
124
+ customName: 'foo/es/{{ member }}',
125
+ },
126
+ ],
123
127
  }),
124
128
  ],
125
129
  });
@@ -135,16 +139,19 @@ import { modulePluginImport } from '@modern-js/plugin-module-import';
135
139
  export default defineConfig({
136
140
  plugins: [
137
141
  modulePluginImport({
138
- pluginImport: [{
139
- libraryName: 'foo',
140
- customName: 'foo/es/{{ member }}'
141
- }],
142
+ pluginImport: [
143
+ {
144
+ libraryName: 'foo',
145
+ customName: 'foo/es/{{ member }}',
146
+ },
147
+ ],
142
148
  }),
143
149
  ],
144
150
  });
145
151
  ```
146
152
 
147
153
  ---
154
+
148
155
  After transformation:
149
156
 
150
157
  ```ts
@@ -159,16 +166,18 @@ The template used here is [handlebars](https://handlebarsjs.com). There are some
159
166
 
160
167
  ```ts focus=8:8
161
168
  import { modulePluginImport } from '@modern-js/plugin-module-import';
162
- import moduleTools, { defineConfig } from '@modern-js/module-tools';
169
+ import { moduleTools, defineConfig } from '@modern-js/module-tools';
163
170
 
164
171
  export default defineConfig({
165
172
  plugins: [
166
173
  moduleTools(),
167
174
  modulePluginImport({
168
- pluginImport: [{
169
- libraryName: 'foo',
170
- customName: 'foo/es/{{ kebabCase member }}',
171
- }],
175
+ pluginImport: [
176
+ {
177
+ libraryName: 'foo',
178
+ customName: 'foo/es/{{ kebabCase member }}',
179
+ },
180
+ ],
172
181
  }),
173
182
  ],
174
183
  });
@@ -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, { defineConfig } from '@modern-js/module-tools';
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, { defineConfig } from '@modern-js/module-tools';
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, { defineConfig } from '@modern-js/module-tools';
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, { defineConfig } from '@modern-js/module-tools';
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, { defineConfig } from '@modern-js/module-tools';
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({