@modern-js/module-tools-docs 2.26.0 → 2.28.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 +15 -0
- package/docs/en/api/config/{build-config.md → build-config.mdx} +11 -5
- package/docs/en/components/register-esbuild-plugin.mdx +14 -0
- package/docs/en/guide/faq/build.mdx +21 -32
- package/docs/zh/api/config/{build-config.md → build-config.mdx} +13 -7
- package/docs/zh/components/register-esbuild-plugin.mdx +14 -0
- package/docs/zh/guide/faq/build.mdx +20 -31
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @modern-js/module-tools-docs
|
|
2
2
|
|
|
3
|
+
## 2.28.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [d3e52e4]
|
|
8
|
+
- @modern-js/doc-plugin-auto-sidebar@2.28.0
|
|
9
|
+
- @modern-js/doc-tools@2.28.0
|
|
10
|
+
|
|
11
|
+
## 2.27.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- @modern-js/doc-tools@2.27.0
|
|
16
|
+
- @modern-js/doc-plugin-auto-sidebar@2.27.0
|
|
17
|
+
|
|
3
18
|
## 2.26.0
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -293,14 +293,14 @@ To prevent excessive global replacement substitution, it is recommended that the
|
|
|
293
293
|
|
|
294
294
|
:::
|
|
295
295
|
|
|
296
|
-
|
|
296
|
+
{/* ## disableSwcTransform
|
|
297
297
|
|
|
298
298
|
Starting with version 2.16.0, SWC Transform is enabled by default for code transformation. If you want to disable this feature, you can use this configuration. Only esbuild Transform is used in this case.
|
|
299
299
|
|
|
300
300
|
The use of SWC Transform can reduce the impact of auxiliary functions on the volume of the constructed product.
|
|
301
301
|
|
|
302
302
|
* **Type**: `boolean`
|
|
303
|
-
* **Default**: `false`
|
|
303
|
+
* **Default**: `false` */}
|
|
304
304
|
|
|
305
305
|
## dts
|
|
306
306
|
|
|
@@ -374,7 +374,7 @@ Path to the tsconfig file
|
|
|
374
374
|
|
|
375
375
|
## esbuildOptions
|
|
376
376
|
|
|
377
|
-
|
|
377
|
+
Used to modify the [esbuild configuration](https://esbuild.github.io/api/).
|
|
378
378
|
|
|
379
379
|
- **Type**: `Function`
|
|
380
380
|
- **Default**: `c => c`
|
|
@@ -392,12 +392,17 @@ export default defineConfig({
|
|
|
392
392
|
});
|
|
393
393
|
```
|
|
394
394
|
|
|
395
|
+
For example, register an esbuild plugin:
|
|
396
|
+
|
|
397
|
+
import RegisterEsbuildPlugin from '@site-docs-en/components/register-esbuild-plugin';
|
|
398
|
+
|
|
399
|
+
<RegisterEsbuildPlugin />
|
|
400
|
+
|
|
395
401
|
:::tip
|
|
396
402
|
We have done many extensions based on the original esbuild build. Therefore, when using this configuration, pay attention to the following:
|
|
397
403
|
|
|
398
|
-
1. Prefer to use the configuration
|
|
404
|
+
1. Prefer to use the configuration that Modern.js Module provides. For example, esbuild does not support `target: 'es5'`, but we support this scenario internally using SWC. Setting `target: 'es5'` through esbuildOptions will result in an error.
|
|
399
405
|
2. Currently, we use enhanced-resolve internally to replace esbuild's resolve algorithm, so modifying esbuild resolve-related configurations is invalid. We plan to switch back in the future.
|
|
400
|
-
3. When using esbuild plugins, you need to add the plugins to the beginning of the plugins array because we also intervene in the entire build process through an esbuild plugin internally. Therefore, custom plugins need to be registered first.
|
|
401
406
|
|
|
402
407
|
:::
|
|
403
408
|
|
|
@@ -1016,6 +1021,7 @@ const tailwind = {
|
|
|
1016
1021
|
],
|
|
1017
1022
|
};
|
|
1018
1023
|
```
|
|
1024
|
+
</details>
|
|
1019
1025
|
|
|
1020
1026
|
When the value is of type `object`, it is merged with the default configuration via `Object.assign`.
|
|
1021
1027
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
```js modern.config.ts
|
|
2
|
+
import { myEsbuildPlugin } from './myEsbuildPlugin';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
buildConfig: {
|
|
6
|
+
esbuildOptions: options => {
|
|
7
|
+
options.plugins = [myEsbuildPlugin, ...options.plugins];
|
|
8
|
+
return option;
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
When adding an esbuild plugin, please note that you need to add the plugin at the beginning of the plugins array. This is because the Modern.js Module is also integrated into the entire build process through an esbuild plugin. Therefore, custom plugins need to be registered with higher priority.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import BuildProductFAQ from '@site-docs-en/components/faq-build-product';
|
|
6
6
|
|
|
7
|
-
<BuildProductFAQ/>
|
|
7
|
+
<BuildProductFAQ />
|
|
8
8
|
|
|
9
9
|
### Initialization of Class Fields
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ TypeSript provides the `useDefineForClassFields` configuration to control the co
|
|
|
12
12
|
|
|
13
13
|
If we have a piece of code:
|
|
14
14
|
|
|
15
|
-
```
|
|
15
|
+
```ts
|
|
16
16
|
class C {
|
|
17
17
|
foo = 100;
|
|
18
18
|
bar: string;
|
|
@@ -21,7 +21,7 @@ class C {
|
|
|
21
21
|
|
|
22
22
|
When `useDefineForClassFields` is `false`, then the compiled code will look like:
|
|
23
23
|
|
|
24
|
-
```
|
|
24
|
+
```ts
|
|
25
25
|
class C {
|
|
26
26
|
constructor() {
|
|
27
27
|
this.foo = 100;
|
|
@@ -31,16 +31,16 @@ class C {
|
|
|
31
31
|
|
|
32
32
|
When `useDefineForClassFields` is `true`, then the compiled code will look like:
|
|
33
33
|
|
|
34
|
-
```
|
|
34
|
+
```ts
|
|
35
35
|
class C {
|
|
36
36
|
constructor() {
|
|
37
|
-
Object.defineProperty(this,
|
|
37
|
+
Object.defineProperty(this, 'foo', {
|
|
38
38
|
enumerable: true,
|
|
39
39
|
configurable: true,
|
|
40
40
|
writable: true,
|
|
41
41
|
value: 100,
|
|
42
42
|
});
|
|
43
|
-
Object.defineProperty(this,
|
|
43
|
+
Object.defineProperty(this, 'bar', {
|
|
44
44
|
enumerable: true,
|
|
45
45
|
configurable: true,
|
|
46
46
|
writable: true,
|
|
@@ -66,12 +66,12 @@ The Modern.js Module will currently process according to the following logic:
|
|
|
66
66
|
|
|
67
67
|
This problem occurs when using something like the following:
|
|
68
68
|
|
|
69
|
-
```
|
|
69
|
+
```ts
|
|
70
70
|
import * as Lodash from 'lodash';
|
|
71
71
|
|
|
72
72
|
export const libs = {
|
|
73
73
|
_: Lodash,
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Current related issues on the `babel-plugin-lodash` Github:
|
|
@@ -82,7 +82,7 @@ The solution to this problem is to remove `babel-plugin-lodash`, since the plugi
|
|
|
82
82
|
|
|
83
83
|
A similar situation occurs with `babel-plugin-import`. If there is code like the following:
|
|
84
84
|
|
|
85
|
-
```
|
|
85
|
+
```ts
|
|
86
86
|
import * as Comps from 'components';
|
|
87
87
|
|
|
88
88
|
export const libs = {
|
|
@@ -104,7 +104,7 @@ import BuildExceptionFAQ from '@site-docs-en/components/faq-build-exception';
|
|
|
104
104
|
|
|
105
105
|
When the product format in the product configuration of the build is ES modules.
|
|
106
106
|
|
|
107
|
-
```
|
|
107
|
+
```ts
|
|
108
108
|
export default defineConfig({
|
|
109
109
|
buildConfig: {
|
|
110
110
|
format: 'esm',
|
|
@@ -121,11 +121,11 @@ If you import a cjs product from a third-party npm package, the resulting produc
|
|
|
121
121
|
1. **First you need to find which third-party package is causing the problem**. For example, if the error message points to the `react` package, then look for a third-party package that has code like `require('react')` in it. For example [`react-draggable`](https://www.npmjs.com/package/react-draggable), which only contains `cjs` products, then the problem is localized to the `react-draggable` package.
|
|
122
122
|
2. Then we need to exclude this package with the following configuration, i.e. **not package problematic third-party packages**.
|
|
123
123
|
|
|
124
|
-
```
|
|
124
|
+
```ts
|
|
125
125
|
export default defineConfig({
|
|
126
126
|
buildConfig: {
|
|
127
127
|
externals: ['react-draggable'],
|
|
128
|
-
}
|
|
128
|
+
},
|
|
129
129
|
});
|
|
130
130
|
```
|
|
131
131
|
|
|
@@ -141,7 +141,7 @@ Therefore, if a component library like this is used in the source code:
|
|
|
141
141
|
|
|
142
142
|
`buildPreset` is used in the build configuration, make the following changes:
|
|
143
143
|
|
|
144
|
-
```
|
|
144
|
+
```js
|
|
145
145
|
module.exports = {
|
|
146
146
|
buildPreset({ extendPreset }) {
|
|
147
147
|
return extendPreset('your-build-preset', {
|
|
@@ -154,12 +154,12 @@ module.exports = {
|
|
|
154
154
|
},
|
|
155
155
|
});
|
|
156
156
|
},
|
|
157
|
-
}
|
|
157
|
+
};
|
|
158
158
|
```
|
|
159
159
|
|
|
160
160
|
Or, if a custom `buildConfig` is used, modify it as follows:
|
|
161
161
|
|
|
162
|
-
```
|
|
162
|
+
```js
|
|
163
163
|
module.exports = {
|
|
164
164
|
buildConfig: {
|
|
165
165
|
style: {
|
|
@@ -169,7 +169,7 @@ module.exports = {
|
|
|
169
169
|
},
|
|
170
170
|
},
|
|
171
171
|
},
|
|
172
|
-
}
|
|
172
|
+
},
|
|
173
173
|
};
|
|
174
174
|
```
|
|
175
175
|
|
|
@@ -193,7 +193,7 @@ module.exports = {
|
|
|
193
193
|
},
|
|
194
194
|
},
|
|
195
195
|
},
|
|
196
|
-
}
|
|
196
|
+
};
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
### Bundle DTS failed
|
|
@@ -206,7 +206,7 @@ So when you encounter a `Bundle DTS failed` error message during the Modern.js M
|
|
|
206
206
|
|
|
207
207
|
### Error reported for `defineConfig` function type: `If there is no reference to "..." then the inferred type of "default" cannot be named`
|
|
208
208
|
|
|
209
|
-
Check if the [`include`](https://www.typescriptlang.org/tsconfig#include)
|
|
209
|
+
Check if the [`include`](https://www.typescriptlang.org/tsconfig#include) configuration exists in the project's tsconfig.json file, and if not, try adding the following:
|
|
210
210
|
|
|
211
211
|
```json
|
|
212
212
|
{
|
|
@@ -226,22 +226,11 @@ The Modern.js Module is based on the esbuild implementation, so if you have spec
|
|
|
226
226
|
|
|
227
227
|
The Modern.js Module provides [`esbuildOptions`](/api/config/build-config.html#esbuildoptions) configuration to allow modification of Modern.js's internal esbuild configuration, so that custom esbuild plugins can be added via this configuration:
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
esbuildOptions: options => {
|
|
233
|
-
options.plugins = [
|
|
234
|
-
...options.plugins,
|
|
235
|
-
yourEsbuildPlugin,
|
|
236
|
-
];
|
|
237
|
-
return option;
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
});
|
|
241
|
-
```
|
|
229
|
+
import RegisterEsbuildPlugin from '@site-docs-en/components/register-esbuild-plugin';
|
|
230
|
+
|
|
231
|
+
<RegisterEsbuildPlugin />
|
|
242
232
|
|
|
243
233
|
### Support for generating TypeScript declaration files for CSS Modules
|
|
244
234
|
|
|
245
235
|
- First Solution: [typed-css-modules](https://github.com/Quramy/typed-css-modules)
|
|
246
236
|
- Second Solution: [postcss-modules-dts](https://www.npmjs.com/package/@guanghechen/postcss-modules-dts)
|
|
247
|
-
|
|
@@ -293,14 +293,14 @@ export default defineConfig({
|
|
|
293
293
|
|
|
294
294
|
:::
|
|
295
295
|
|
|
296
|
-
|
|
296
|
+
{/* ## disableSwcTransform
|
|
297
297
|
|
|
298
298
|
从 2.16.0 版本开始,默认开启 SWC Transform 进行代码转换。如果想要关闭该功能,可以使用该配置。此时仅使用 esbuild Transform。
|
|
299
299
|
|
|
300
300
|
使用 SWC Transform 可以减小辅助函数对构建产物体积的影响。
|
|
301
301
|
|
|
302
302
|
* 类型:`boolean`
|
|
303
|
-
* 默认值:`false`
|
|
303
|
+
* 默认值:`false` */}
|
|
304
304
|
|
|
305
305
|
## dts
|
|
306
306
|
|
|
@@ -373,12 +373,12 @@ TypeScript 配置文件的路径。
|
|
|
373
373
|
|
|
374
374
|
## esbuildOptions
|
|
375
375
|
|
|
376
|
-
|
|
376
|
+
用于修改底层的 [esbuild 配置](https://esbuild.github.io/api/)。
|
|
377
377
|
|
|
378
378
|
- 类型: `Function`
|
|
379
379
|
- 默认值: `c => c`
|
|
380
380
|
|
|
381
|
-
|
|
381
|
+
例如,我们需要修改生成文件的后缀:
|
|
382
382
|
|
|
383
383
|
```js modern.config.ts
|
|
384
384
|
export default defineConfig({
|
|
@@ -391,12 +391,17 @@ export default defineConfig({
|
|
|
391
391
|
});
|
|
392
392
|
```
|
|
393
393
|
|
|
394
|
+
例如,注册一个 esbuild 插件:
|
|
395
|
+
|
|
396
|
+
import RegisterEsbuildPlugin from '@site-docs/components/register-esbuild-plugin';
|
|
397
|
+
|
|
398
|
+
<RegisterEsbuildPlugin />
|
|
399
|
+
|
|
394
400
|
:::tip
|
|
395
401
|
我们在原本 esbuild 构建的基础上做了许多扩展,因此使用此配置需要注意以下几点:
|
|
396
402
|
|
|
397
|
-
1.
|
|
398
|
-
2.
|
|
399
|
-
3. 使用 esbuild 插件时需要将插件加在 plugins 数组的头部,因为我们内部也是通过一个 esbuild 插件介入到整个构建流程中去的,因此需要将自定义插件优先注册。
|
|
403
|
+
1. 优先使用 Modern.js Module 提供的配置,例如 esbuild 并不支持 `target: 'es5'`,但我们内部使用 SWC 支持了此场景,此时通过 `esbuildOptions` 设置`target: 'es5'`会报错。
|
|
404
|
+
2. 目前我们内部使用 `enhanced-resolve` 替代了 esbuild 的 resolve 解析算法,所以修改 esbuild resolve 相关配置无效,计划在未来会切换回来。
|
|
400
405
|
|
|
401
406
|
:::
|
|
402
407
|
|
|
@@ -1019,6 +1024,7 @@ const tailwind = {
|
|
|
1019
1024
|
],
|
|
1020
1025
|
};
|
|
1021
1026
|
```
|
|
1027
|
+
</details>
|
|
1022
1028
|
|
|
1023
1029
|
值为 `object` 类型时,与默认配置通过 `Object.assign` 合并。
|
|
1024
1030
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
```js modern.config.ts
|
|
2
|
+
import { myEsbuildPlugin } from './myEsbuildPlugin';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
buildConfig: {
|
|
6
|
+
esbuildOptions: options => {
|
|
7
|
+
options.plugins = [myEsbuildPlugin, ...options.plugins];
|
|
8
|
+
return option;
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
在增加 esbuild 插件时,请注意你需要将插件加在 plugins 数组的头部,因为 Modern.js Module 内部也是通过一个 esbuild 插件介入到整个构建流程中去的,因此需要将自定义插件优先注册。
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import BuildProductFAQ from '@site-docs/components/faq-build-product';
|
|
6
6
|
|
|
7
|
-
<BuildProductFAQ/>
|
|
7
|
+
<BuildProductFAQ />
|
|
8
8
|
|
|
9
9
|
### Class Fields 的初始化处理
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ TypeSript 提供了 `useDefineForClassFields` 配置用于控制对于 `public c
|
|
|
12
12
|
|
|
13
13
|
如果有一段代码:
|
|
14
14
|
|
|
15
|
-
```
|
|
15
|
+
```ts
|
|
16
16
|
class C {
|
|
17
17
|
foo = 100;
|
|
18
18
|
bar: string;
|
|
@@ -21,7 +21,7 @@ class C {
|
|
|
21
21
|
|
|
22
22
|
当 `useDefineForClassFields` 为 `false` 的时候,则编译后的代码会变为:
|
|
23
23
|
|
|
24
|
-
```
|
|
24
|
+
```ts
|
|
25
25
|
class C {
|
|
26
26
|
constructor() {
|
|
27
27
|
this.foo = 100;
|
|
@@ -31,16 +31,16 @@ class C {
|
|
|
31
31
|
|
|
32
32
|
当 `useDefineForClassFields` 为 `true` 的时候,则编译后的代码会变为:
|
|
33
33
|
|
|
34
|
-
```
|
|
34
|
+
```ts
|
|
35
35
|
class C {
|
|
36
36
|
constructor() {
|
|
37
|
-
Object.defineProperty(this,
|
|
37
|
+
Object.defineProperty(this, 'foo', {
|
|
38
38
|
enumerable: true,
|
|
39
39
|
configurable: true,
|
|
40
40
|
writable: true,
|
|
41
41
|
value: 100,
|
|
42
42
|
});
|
|
43
|
-
Object.defineProperty(this,
|
|
43
|
+
Object.defineProperty(this, 'bar', {
|
|
44
44
|
enumerable: true,
|
|
45
45
|
configurable: true,
|
|
46
46
|
writable: true,
|
|
@@ -66,12 +66,12 @@ Modern.js Module 目前会根据下面的逻辑进行处理:
|
|
|
66
66
|
|
|
67
67
|
当使用类似下面的方式的时候,会出现这个问题:
|
|
68
68
|
|
|
69
|
-
```
|
|
69
|
+
```ts
|
|
70
70
|
import * as Lodash from 'lodash';
|
|
71
71
|
|
|
72
72
|
export const libs = {
|
|
73
73
|
_: Lodash,
|
|
74
|
-
}
|
|
74
|
+
};
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
目前在 `babel-plugin-lodash` Github 上的相关 Issue:
|
|
@@ -82,7 +82,7 @@ export const libs = {
|
|
|
82
82
|
|
|
83
83
|
类似的情况在 `babel-plugin-import` 上也可能会出现。比如有类似如下的代码:
|
|
84
84
|
|
|
85
|
-
```
|
|
85
|
+
```ts
|
|
86
86
|
import * as Comps from 'components';
|
|
87
87
|
|
|
88
88
|
export const libs = {
|
|
@@ -104,7 +104,7 @@ import BuildExceptionFAQ from '@site-docs/components/faq-build-exception';
|
|
|
104
104
|
|
|
105
105
|
当构建的产物配置中产物格式为 ES modules 的时候:
|
|
106
106
|
|
|
107
|
-
```
|
|
107
|
+
```ts
|
|
108
108
|
export default defineConfig({
|
|
109
109
|
buildConfig: {
|
|
110
110
|
format: 'esm',
|
|
@@ -121,11 +121,11 @@ export default defineConfig({
|
|
|
121
121
|
1. **首先需要找到是哪个第三方包引起的问题**。例如报错信息中指向了 `react` 这个包,那么就要寻找在哪个第三方包里存在 `require('react')` 这样的代码。比如 [`react-draggable`](https://www.npmjs.com/package/react-draggable) ,这个包仅包含 `cjs` 产物,那么问题定位到 `react-draggable` 这个包。
|
|
122
122
|
2. 然后我们需要将这个包通过下面的配置进行排除,即**不打包存在问题的第三方包**。
|
|
123
123
|
|
|
124
|
-
```
|
|
124
|
+
```ts
|
|
125
125
|
export default defineConfig({
|
|
126
126
|
buildConfig: {
|
|
127
127
|
externals: ['react-draggable'],
|
|
128
|
-
}
|
|
128
|
+
},
|
|
129
129
|
});
|
|
130
130
|
```
|
|
131
131
|
|
|
@@ -133,7 +133,6 @@ export default defineConfig({
|
|
|
133
133
|
|
|
134
134
|
- [When using esbuild with external react I get Dynamic require of "react" is not supported](https://stackoverflow.com/questions/68423950/when-using-esbuild-with-external-react-i-get-dynamic-require-of-react-is-not-s)
|
|
135
135
|
|
|
136
|
-
|
|
137
136
|
### 编译过程中,因为某个组件库的 less 文件报错:`'Operation on an invalid type'`
|
|
138
137
|
|
|
139
138
|
可能是因为该组件库依赖的 Less 版本是 v3,而 Modern.js Module 默认是 v4。v3 与 v4 在 `math` 配置上存在有 Break Change,可以查看这个[链接](https://stackoverflow.com/questions/73298187/less-error-operation-on-an-invalid-type-in-antd-dependency) 了解详情。
|
|
@@ -142,7 +141,7 @@ export default defineConfig({
|
|
|
142
141
|
|
|
143
142
|
在构建配置中使用了 `buildPreset` 的情况下,按照下面进行修改:
|
|
144
143
|
|
|
145
|
-
```
|
|
144
|
+
```js
|
|
146
145
|
module.exports = {
|
|
147
146
|
buildPreset({ extendPreset }) {
|
|
148
147
|
return extendPreset('your-build-preset', {
|
|
@@ -155,12 +154,12 @@ module.exports = {
|
|
|
155
154
|
},
|
|
156
155
|
});
|
|
157
156
|
},
|
|
158
|
-
}
|
|
157
|
+
};
|
|
159
158
|
```
|
|
160
159
|
|
|
161
160
|
或者使用了自定义的 `buildConfig` 的情况下,按照下面进行修改:
|
|
162
161
|
|
|
163
|
-
```
|
|
162
|
+
```js
|
|
164
163
|
module.exports = {
|
|
165
164
|
buildConfig: {
|
|
166
165
|
style: {
|
|
@@ -170,7 +169,7 @@ module.exports = {
|
|
|
170
169
|
},
|
|
171
170
|
},
|
|
172
171
|
},
|
|
173
|
-
}
|
|
172
|
+
},
|
|
174
173
|
};
|
|
175
174
|
```
|
|
176
175
|
|
|
@@ -194,7 +193,7 @@ module.exports = {
|
|
|
194
193
|
},
|
|
195
194
|
},
|
|
196
195
|
},
|
|
197
|
-
}
|
|
196
|
+
};
|
|
198
197
|
```
|
|
199
198
|
|
|
200
199
|
### Bundle DTS failed
|
|
@@ -227,19 +226,9 @@ Modern.js Module 基于 esbuild 实现,因此如果有特殊需求或者想要
|
|
|
227
226
|
|
|
228
227
|
Modern.js Module 提供了 [`esbuildOptions`](/api/config/build-config.html#esbuildoptions) 配置允许修改 Modern.js Module 内部的 esbuild 配置,因此可以通过该配置来增加自定义的 esbuild 插件:
|
|
229
228
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
esbuildOptions: options => {
|
|
234
|
-
options.plugins = [
|
|
235
|
-
...options.plugins,
|
|
236
|
-
yourEsbuildPlugin,
|
|
237
|
-
];
|
|
238
|
-
return option;
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
```
|
|
229
|
+
import RegisterEsbuildPlugin from '@site-docs/components/register-esbuild-plugin';
|
|
230
|
+
|
|
231
|
+
<RegisterEsbuildPlugin />
|
|
243
232
|
|
|
244
233
|
### 支持生成 CSS Modules 的 TypeScript 声明文件
|
|
245
234
|
|
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.28.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.28.0",
|
|
20
|
+
"@modern-js/doc-tools": "2.28.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"dev": "modern dev",
|