@modern-js/module-tools-docs 2.39.1 → 2.40.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 +4 -0
- package/docs/en/api/config/build-config.mdx +5 -2
- package/docs/en/guide/advance/in-depth-about-build.md +1 -1
- package/docs/en/guide/basic/command-preview.md +1 -0
- package/docs/en/guide/faq/build.mdx +9 -2
- package/docs/en/guide/faq/storybook.mdx +1 -3
- package/docs/en/plugins/official-list/plugin-vue.mdx +9 -1
- package/docs/zh/api/config/build-config.mdx +3 -0
- package/docs/zh/guide/advance/in-depth-about-build.md +1 -1
- package/docs/zh/guide/basic/command-preview.md +1 -0
- package/docs/zh/guide/faq/build.mdx +9 -2
- package/docs/zh/guide/faq/storybook.mdx +1 -2
- package/docs/zh/plugins/official-list/plugin-vue.mdx +9 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -868,7 +868,8 @@ export default defineConfig({
|
|
|
868
868
|
|
|
869
869
|
## platform
|
|
870
870
|
|
|
871
|
-
Generates code for the node environment by default, you can also specify `browser` which will generate code for the browser environment
|
|
871
|
+
Generates code for the node environment by default, you can also specify `browser` which will generate code for the browser environment.
|
|
872
|
+
See [esbuild.platform](https://esbuild.github.io/api/#platform) learn more.
|
|
872
873
|
|
|
873
874
|
- **Type**: `'browser' | 'node'`
|
|
874
875
|
- **Default**: `'node'`
|
|
@@ -1022,6 +1023,7 @@ After adding this configuration, the sideEffects field in package.json will no l
|
|
|
1022
1023
|
## sourceDir
|
|
1023
1024
|
|
|
1024
1025
|
Specify the source directory of the build, default is `src`, which is used to generate the corresponding output directory based on the source directory structure when building `bundleless`.
|
|
1026
|
+
Same as [esbuild.outbase](https://esbuild.github.io/api/#outbase).
|
|
1025
1027
|
|
|
1026
1028
|
- **Type**: `string`
|
|
1027
1029
|
- **Default**: `src`
|
|
@@ -1042,7 +1044,8 @@ Sets the format of the source code. By default, the source code will be treated
|
|
|
1042
1044
|
|
|
1043
1045
|
## splitting
|
|
1044
1046
|
|
|
1045
|
-
Whether to enable code splitting
|
|
1047
|
+
Whether to enable code splitting.
|
|
1048
|
+
Only support [format: 'esm'](#format-esm) and [format: 'cjs'](#format-cjs),see [esbuild.splitting](https://esbuild.github.io/api/#splitting) learn more.
|
|
1046
1049
|
|
|
1047
1050
|
- **Type**: `boolean`
|
|
1048
1051
|
- **Default**: `false`
|
|
@@ -244,7 +244,7 @@ With `buildType: 'bundleless'`, type files are generated using the project's `ts
|
|
|
244
244
|
|
|
245
245
|
The **Modern.js Module also supports bundling of type files**, although care needs to be taken when using this feature.
|
|
246
246
|
|
|
247
|
-
- Some third-party dependencies have incorrect syntax that can cause the bundling process to fail. So in this case, you need to exclude such third-party packages manually with [`buildConfig.externals`](/en/api/config/build-config#externals).
|
|
247
|
+
- Some third-party dependencies have incorrect syntax that can cause the bundling process to fail. So in this case, you need to exclude such third-party packages manually with [`buildConfig.externals`](/en/api/config/build-config#externals) or close [dts.respectExternal](/api/config/build-config#dtsrespectexternal) to external all third-party packages types.
|
|
248
248
|
- It is not possible to handle the case where the type file of a third-party dependency points to a `.ts` file. For example, the `package.json` of a third-party dependency contains something like this: `{"types": ". /src/index.ts"}`.
|
|
249
249
|
|
|
250
250
|
### Alias Conversion
|
|
@@ -20,6 +20,7 @@ Options:
|
|
|
20
20
|
--platform [platform] Build artifacts for all or specified platforms
|
|
21
21
|
--no-dts disables DTS type file generation and type checking
|
|
22
22
|
--no-clear disables automatic clearing of output directories
|
|
23
|
+
-c, --config <config> Specify the path to the config file (default: "modern.config.j(t)s")
|
|
23
24
|
-h, --help Show information about the current command
|
|
24
25
|
```
|
|
25
26
|
|
|
@@ -214,6 +214,13 @@ Check if the [`include`](https://www.typescriptlang.org/tsconfig#include) config
|
|
|
214
214
|
}
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
+
### Bundleless DTS failed
|
|
218
|
+
|
|
219
|
+
In the bundleless scenario, it's `tsc` that generates the type declaration file directly. You can find the problem file by printing the error message in the terminal. For source code files, it is recommended to fix the type problem, which can better enable reuse of your package. However. if you encounter a type checking problem with a thrid-party package:
|
|
220
|
+
|
|
221
|
+
1. enable [skipLibCheck](https://www.typescriptlang.org/tsconfig#skipLibCheck) to skip the d.ts check of the thrid-party package.
|
|
222
|
+
2. If the package exports ts files directly, skipLibCheck will not work because it can only skip the d.ts check, so you can only turn off [dts.abortOnError](/api/config/build-config.html#dtsabortonerror) to ignore these errors.
|
|
223
|
+
|
|
217
224
|
## Other FAQ
|
|
218
225
|
|
|
219
226
|
import BuildOtherFAQ from '@site-docs-en/components/faq-build-other';
|
|
@@ -239,7 +246,7 @@ import RegisterEsbuildPlugin from '@site-docs-en/components/register-esbuild-plu
|
|
|
239
246
|
import { defineConfig } from '@modern-js/module-tools';
|
|
240
247
|
|
|
241
248
|
export default defineConfig(async () => {
|
|
242
|
-
const { dts } =
|
|
249
|
+
const { dts } = await import('@guanghechen/postcss-modules-dts');
|
|
243
250
|
return {
|
|
244
251
|
buildConfig: {
|
|
245
252
|
style: {
|
|
@@ -247,6 +254,6 @@ export default defineConfig(async () => {
|
|
|
247
254
|
},
|
|
248
255
|
},
|
|
249
256
|
// custom config
|
|
250
|
-
}
|
|
257
|
+
};
|
|
251
258
|
});
|
|
252
259
|
```
|
|
@@ -6,9 +6,7 @@ import BuildStorybookFAQ from '@site-docs-en/components/faq-storybook';
|
|
|
6
6
|
|
|
7
7
|
## Storybook v7 Support
|
|
8
8
|
|
|
9
|
-
Storybook v7
|
|
10
|
-
|
|
11
|
-
Related Issue: [#3376](https://github.com/web-infra-dev/modern.js/issues/3376).
|
|
9
|
+
Storybook v7 is now fully supported and has become our recommended version.
|
|
12
10
|
|
|
13
11
|
## Using Storybook Addon or other configurations does not work
|
|
14
12
|
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
The Vue plugin provides support for building Vue 3 components. The plugin internally integrates [esbuild-plugin-vue3](https://github.com/pipe01/esbuild-plugin-vue3) and [@vue/babel-plugin-jsx](https://github.com/vuejs/babel-plugin-jsx)。
|
|
4
4
|
|
|
5
5
|
:::warning
|
|
6
|
-
|
|
6
|
+
Notice that we have some limitation:
|
|
7
|
+
|
|
8
|
+
1. The current implementation of this plugin integrates directly with the community plugin and therefore does not support writing jsx/tsx in sfc.
|
|
9
|
+
2. If you want to generate d.ts for the components, please use the official recommendation [vue-tsc](https://www.npmjs.com/package/vue-tsc).
|
|
10
|
+
3. Only support bundle, we recommend to set input to `['src/**/*.vue']` or `['src/index.ts']`.
|
|
7
11
|
:::
|
|
8
12
|
|
|
9
13
|
## Quick start
|
|
@@ -24,6 +28,10 @@ import { modulePluginVue } from '@modern-js/plugin-module-vue';
|
|
|
24
28
|
|
|
25
29
|
export default defineConfig({
|
|
26
30
|
plugins: [moduleTools(), modulePluginVue()],
|
|
31
|
+
buildType: 'bundle',
|
|
32
|
+
format: 'esm',
|
|
33
|
+
input: ['src/index.vue'],
|
|
34
|
+
dts: false,
|
|
27
35
|
});
|
|
28
36
|
```
|
|
29
37
|
|
|
@@ -864,6 +864,7 @@ export default defineConfig({
|
|
|
864
864
|
## platform
|
|
865
865
|
|
|
866
866
|
默认生成用于 Node.js 环境下的代码,你也可以指定为 `browser`,会生成用于浏览器环境的代码。
|
|
867
|
+
查看[esbuild.platform](https://esbuild.github.io/api/#platform)了解更多。
|
|
867
868
|
|
|
868
869
|
- 类型: `'browser' | 'node'`
|
|
869
870
|
- 默认值: `'node'`
|
|
@@ -1019,6 +1020,7 @@ export default defineConfig({
|
|
|
1019
1020
|
## sourceDir
|
|
1020
1021
|
|
|
1021
1022
|
指定构建的源码目录,默认为 `src`,用于在 `bundleless` 构建时基于源码目录结构生成对应的产物目录。
|
|
1023
|
+
等同于[esbuild.outbase](https://esbuild.github.io/api/#outbase)。
|
|
1022
1024
|
|
|
1023
1025
|
- 类型: `string`
|
|
1024
1026
|
- 默认值: `src`
|
|
@@ -1044,6 +1046,7 @@ export default defineConfig({
|
|
|
1044
1046
|
## splitting
|
|
1045
1047
|
|
|
1046
1048
|
是否开启代码分割。
|
|
1049
|
+
仅支持 [format: 'esm'](#format-esm) 和 [format: 'cjs'](#format-cjs),查看[esbuild.splitting](https://esbuild.github.io/api/#splitting)了解更多。
|
|
1047
1050
|
|
|
1048
1051
|
- 类型: `boolean`
|
|
1049
1052
|
- 默认值: `false`
|
|
@@ -244,7 +244,7 @@ export default defineConfig({
|
|
|
244
244
|
|
|
245
245
|
**Modern.js Module 同时还支持对类型文件进行打包**,不过使用该功能的时候需要注意:
|
|
246
246
|
|
|
247
|
-
- 一些第三方依赖存在错误的语法会导致打包过程失败。因此对于这种情况,需要手动通过 [`buildConfig.externals`](/api/config/build-config#externals)
|
|
247
|
+
- 一些第三方依赖存在错误的语法会导致打包过程失败。因此对于这种情况,需要手动通过 [`buildConfig.externals`](/api/config/build-config#externals) 将这类第三方包排除,或者直接关闭[dts.respectExternal](/api/config/build-config#dtsrespectexternal)从而不打包任何三方包类型。
|
|
248
248
|
- 对于第三方依赖的类型文件指向的是一个 `.ts` 文件的情况,目前无法处理。比如第三方依赖的 `package.json` 中存在这样的内容: `{"types": "./src/index.ts"}`。
|
|
249
249
|
|
|
250
250
|
### 别名转换
|
|
@@ -214,6 +214,13 @@ module.exports = {
|
|
|
214
214
|
}
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
+
### Bundleless DTS failed
|
|
218
|
+
|
|
219
|
+
在不打包的场景下,是直接 `tsc` 生成类型声明文件。通过终端打印的错误信息,你可以找到问题文件。对于源码文件,推荐将类型问题进行修复,这能够更好地使你的包得到复用。但如果遇到三方包的类型检查问题:
|
|
220
|
+
|
|
221
|
+
1. 开启 [skipLibCheck](https://www.typescriptlang.org/tsconfig#skipLibCheck) 来跳过三方包的 d.ts 检查。
|
|
222
|
+
2. 如果三方包直接导出 ts 文件, skipLibCheck 将会失效,因为其只能跳过 d.ts 检查,因此你只能关闭[dts.abortOnError](<(/api/config/build-config.html#dtsabortonerror)>)来忽略这些错误。
|
|
223
|
+
|
|
217
224
|
## 其他
|
|
218
225
|
|
|
219
226
|
import BuildOtherFAQ from '@site-docs/components/faq-build-other';
|
|
@@ -239,7 +246,7 @@ import RegisterEsbuildPlugin from '@site-docs/components/register-esbuild-plugin
|
|
|
239
246
|
import { defineConfig } from '@modern-js/module-tools';
|
|
240
247
|
|
|
241
248
|
export default defineConfig(async () => {
|
|
242
|
-
const { dts } =
|
|
249
|
+
const { dts } = await import('@guanghechen/postcss-modules-dts');
|
|
243
250
|
return {
|
|
244
251
|
buildConfig: {
|
|
245
252
|
style: {
|
|
@@ -247,6 +254,6 @@ export default defineConfig(async () => {
|
|
|
247
254
|
},
|
|
248
255
|
},
|
|
249
256
|
// 你的自定义配置
|
|
250
|
-
}
|
|
257
|
+
};
|
|
251
258
|
});
|
|
252
259
|
```
|
|
@@ -6,8 +6,7 @@ import BuildStorybookFAQ from '@site-docs/components/faq-storybook';
|
|
|
6
6
|
|
|
7
7
|
## 支持 Storybook v7
|
|
8
8
|
|
|
9
|
-
Storybook v7
|
|
10
|
-
相关 Issue:[#3376](https://github.com/web-infra-dev/modern.js/issues/3376)。
|
|
9
|
+
Storybook v7 目前已全面支持并已成为我们的推荐使用版本。
|
|
11
10
|
|
|
12
11
|
## 使用 Storybook Addon 或者其他配置不生效
|
|
13
12
|
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
Vue 插件提供了对 Vue 3 组件构建的支持,插件内部集成了 [esbuild-plugin-vue3](https://github.com/pipe01/esbuild-plugin-vue3) 和 [@vue/babel-plugin-jsx](https://github.com/vuejs/babel-plugin-jsx)。
|
|
4
4
|
|
|
5
5
|
:::warning
|
|
6
|
-
|
|
6
|
+
请注意,此插件仍有一些用法限制:
|
|
7
|
+
|
|
8
|
+
1. 目前此插件的实现是直接集成社区插件,因此不支持在 sfc 里写 jsx/tsx。
|
|
9
|
+
2. 如果要为组件生成 d.ts,请使用官方推荐方式 [vue-tsc](https://www.npmjs.com/package/vue-tsc)。
|
|
10
|
+
3. 仅支持打包场景,推荐将 input 设置为 `['src/**/*.vue']` 或者 `['src/index.ts']`。
|
|
7
11
|
:::
|
|
8
12
|
|
|
9
13
|
## 快速开始
|
|
@@ -24,6 +28,10 @@ import { modulePluginVue } from '@modern-js/plugin-module-vue';
|
|
|
24
28
|
|
|
25
29
|
export default defineConfig({
|
|
26
30
|
plugins: [moduleTools(), modulePluginVue()],
|
|
31
|
+
buildType: 'bundle',
|
|
32
|
+
format: 'esm',
|
|
33
|
+
input: ['src/index.vue'],
|
|
34
|
+
dts: false,
|
|
27
35
|
});
|
|
28
36
|
```
|
|
29
37
|
|
package/package.json
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
"directory": "packages/document/module-doc"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
|
-
"version": "2.
|
|
12
|
+
"version": "2.40.0",
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"react": "^18.2.0",
|
|
16
16
|
"react-dom": "^18.2.0",
|
|
17
|
-
"rspress": "1.
|
|
18
|
-
"@rspress/shared": "1.
|
|
19
|
-
"@modern-js/doc-plugin-auto-sidebar": "2.
|
|
17
|
+
"rspress": "1.5.0",
|
|
18
|
+
"@rspress/shared": "1.5.0",
|
|
19
|
+
"@modern-js/doc-plugin-auto-sidebar": "2.40.0"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"dev": "rspress dev",
|