@modern-js/module-tools-docs 2.25.2-beta.0 → 2.26.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 +16 -0
- package/docs/en/api/config/build-config.md +10 -10
- package/docs/en/api/config/build-preset.mdx +4 -4
- package/docs/en/guide/advance/asset.mdx +2 -2
- package/docs/en/guide/advance/build-umd.mdx +9 -9
- package/docs/en/guide/advance/copy.md +1 -1
- package/docs/en/guide/advance/external-dependency.mdx +2 -2
- package/docs/en/guide/advance/in-depth-about-build.md +11 -11
- package/docs/en/guide/advance/in-depth-about-dev-command.md +1 -1
- package/docs/en/guide/basic/before-getting-started.md +1 -1
- package/docs/en/guide/basic/command-preview.md +5 -5
- package/docs/en/guide/basic/modify-output-product.md +18 -18
- package/docs/en/guide/basic/using-storybook.mdx +1 -1
- package/docs/en/guide/best-practices/components.mdx +10 -10
- package/docs/en/guide/faq/build.mdx +1 -1
- package/docs/en/guide/intro/welcome.md +2 -2
- package/docs/en/plugins/guide/getting-started.mdx +1 -1
- package/docs/en/plugins/guide/plugin-object.mdx +2 -2
- package/docs/en/plugins/guide/setup-function.mdx +1 -1
- package/docs/zh/api/config/build-config.md +1 -1
- package/docs/zh/guide/faq/build.mdx +1 -1
- package/package.json +3 -3
- package/doc_build/api/config/build-config.html +0 -522
- package/doc_build/api/config/build-preset.html +0 -71
- package/doc_build/api/config/design-system.html +0 -113
- package/doc_build/api/config/dev.html +0 -40
- package/doc_build/api/config/plugins.html +0 -31
- package/doc_build/api/config/testing.html +0 -31
- package/doc_build/api/index.html +0 -11
- package/doc_build/api/plugin-api/plugin-hooks.html +0 -122
- package/doc_build/components/faq-build-exception.html +0 -11
- package/doc_build/components/faq-build-other.html +0 -11
- package/doc_build/components/faq-build-product.html +0 -11
- package/doc_build/components/faq-storybook.html +0 -11
- package/doc_build/components/faq-test.html +0 -11
- package/doc_build/en/api/config/build-config.html +0 -443
- package/doc_build/en/api/config/build-preset.html +0 -71
- package/doc_build/en/api/config/design-system.html +0 -127
- package/doc_build/en/api/config/dev.html +0 -40
- package/doc_build/en/api/config/plugins.html +0 -31
- package/doc_build/en/api/config/testing.html +0 -31
- package/doc_build/en/api/index.html +0 -11
- package/doc_build/en/api/plugin-api/plugin-hooks.html +0 -122
- package/doc_build/en/components/faq-build-exception.html +0 -11
- package/doc_build/en/components/faq-build-other.html +0 -11
- package/doc_build/en/components/faq-build-product.html +0 -11
- package/doc_build/en/components/faq-storybook.html +0 -11
- package/doc_build/en/components/faq-test.html +0 -11
- package/doc_build/en/guide/advance/asset.html +0 -31
- package/doc_build/en/guide/advance/build-umd.html +0 -42
- package/doc_build/en/guide/advance/copy.html +0 -52
- package/doc_build/en/guide/advance/external-dependency.html +0 -32
- package/doc_build/en/guide/advance/in-depth-about-build.html +0 -123
- package/doc_build/en/guide/advance/in-depth-about-dev-command.html +0 -32
- package/doc_build/en/guide/advance/theme-config.html +0 -39
- package/doc_build/en/guide/basic/before-getting-started.html +0 -97
- package/doc_build/en/guide/basic/command-preview.html +0 -73
- package/doc_build/en/guide/basic/modify-output-product.html +0 -113
- package/doc_build/en/guide/basic/publish-your-project.html +0 -60
- package/doc_build/en/guide/basic/test-your-project.html +0 -41
- package/doc_build/en/guide/basic/use-micro-generator.html +0 -47
- package/doc_build/en/guide/basic/using-storybook.html +0 -76
- package/doc_build/en/guide/best-practices/components.html +0 -121
- package/doc_build/en/guide/faq/build.html +0 -91
- package/doc_build/en/guide/faq/index.html +0 -17
- package/doc_build/en/guide/faq/storybook.html +0 -53
- package/doc_build/en/guide/faq/test.html +0 -16
- package/doc_build/en/guide/intro/getting-started.html +0 -53
- package/doc_build/en/guide/intro/welcome.html +0 -23
- package/doc_build/en/guide/intro/why-module-engineering-solution.html +0 -19
- package/doc_build/en/index.html +0 -11
- package/doc_build/en/plugins/guide/getting-started.html +0 -25
- package/doc_build/en/plugins/guide/plugin-object.html +0 -24
- package/doc_build/en/plugins/guide/setup-function.html +0 -40
- package/doc_build/en/plugins/official-list/overview.html +0 -19
- package/doc_build/en/plugins/official-list/plugin-babel.html +0 -23
- package/doc_build/en/plugins/official-list/plugin-banner.html +0 -40
- package/doc_build/en/plugins/official-list/plugin-import.html +0 -44
- package/doc_build/en/plugins/official-list/plugin-node-polyfill.html +0 -88
- package/doc_build/en/plugins/official-list/plugin-polyfill.html +0 -28
- package/doc_build/guide/advance/asset.html +0 -31
- package/doc_build/guide/advance/build-umd.html +0 -42
- package/doc_build/guide/advance/copy.html +0 -52
- package/doc_build/guide/advance/external-dependency.html +0 -31
- package/doc_build/guide/advance/in-depth-about-build.html +0 -123
- package/doc_build/guide/advance/in-depth-about-dev-command.html +0 -32
- package/doc_build/guide/advance/theme-config.html +0 -38
- package/doc_build/guide/basic/before-getting-started.html +0 -97
- package/doc_build/guide/basic/command-preview.html +0 -73
- package/doc_build/guide/basic/modify-output-product.html +0 -110
- package/doc_build/guide/basic/publish-your-project.html +0 -62
- package/doc_build/guide/basic/test-your-project.html +0 -43
- package/doc_build/guide/basic/use-micro-generator.html +0 -45
- package/doc_build/guide/basic/using-storybook.html +0 -74
- package/doc_build/guide/best-practices/components.html +0 -121
- package/doc_build/guide/faq/build.html +0 -91
- package/doc_build/guide/faq/index.html +0 -17
- package/doc_build/guide/faq/storybook.html +0 -53
- package/doc_build/guide/faq/test.html +0 -16
- package/doc_build/guide/intro/getting-started.html +0 -50
- package/doc_build/guide/intro/welcome.html +0 -23
- package/doc_build/guide/intro/why-module-engineering-solution.html +0 -19
- package/doc_build/index.html +0 -11
- package/doc_build/plugins/guide/getting-started.html +0 -25
- package/doc_build/plugins/guide/plugin-object.html +0 -24
- package/doc_build/plugins/guide/setup-function.html +0 -40
- package/doc_build/plugins/official-list/overview.html +0 -19
- package/doc_build/plugins/official-list/plugin-babel.html +0 -23
- package/doc_build/plugins/official-list/plugin-banner.html +0 -40
- package/doc_build/plugins/official-list/plugin-import.html +0 -44
- package/doc_build/plugins/official-list/plugin-node-polyfill.html +0 -88
- package/doc_build/plugins/official-list/plugin-polyfill.html +0 -28
- package/doc_build/route.json +0 -10
- package/doc_build/ssr/bundles/main.js +0 -30
- package/doc_build/ssr/bundles/main.js.LICENSE.txt +0 -103
- package/doc_build/static/css/defaultVendors~docs_en_api_config_build-config_md~docs_en_api_config_build-preset_mdx~docs_en~2cd1be.71af0621.css +0 -1
- package/doc_build/static/css/main.1e1c5ea3.css +0 -17
- package/doc_build/static/js/async/default~docs_en_guide_faq_build_mdx~docs_en_guide_faq_storybook_mdx~docs_en_guide_faq_test_md~931d29.a2443c41.js +0 -1
- package/doc_build/static/js/async/docs_en_api_config_build-config_md.47c13184.js +0 -1
- package/doc_build/static/js/async/docs_en_api_config_build-preset_mdx.240d175b.js +0 -1
- package/doc_build/static/js/async/docs_en_api_config_design-system_md.b2ec1ff7.js +0 -1
- package/doc_build/static/js/async/docs_en_api_config_dev_md.6ad208aa.js +0 -1
- package/doc_build/static/js/async/docs_en_api_config_plugins_md.da21c1a9.js +0 -1
- package/doc_build/static/js/async/docs_en_api_config_testing_md.5655d56b.js +0 -1
- package/doc_build/static/js/async/docs_en_api_index_md.b332bf64.js +0 -1
- package/doc_build/static/js/async/docs_en_api_plugin-api_plugin-hooks_md.b0f73e0d.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_advance_asset_mdx.d302e90c.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_advance_build-umd_mdx.554fa073.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_advance_copy_md.78b33f73.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_advance_external-dependency_mdx.507e4091.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_advance_in-depth-about-build_md.207e8b25.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_advance_in-depth-about-dev-command_md.72d6b6fc.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_advance_theme-config_mdx.168a5eec.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_basic_before-getting-started_md.a00933ab.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_basic_command-preview_md.5e63d7ad.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_basic_modify-output-product_md.abd250e1.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_basic_publish-your-project_md.3b098b03.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_basic_test-your-project_mdx.b86e9b69.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_basic_use-micro-generator_md.e03b16c8.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_basic_using-storybook_mdx.32e9b389.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_best-practices_components_mdx.a56e369b.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_faq_build_mdx.81c243c7.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_faq_index_md.85367f4a.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_faq_storybook_mdx.d6b26cfd.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_faq_test_mdx.a7a1c8b5.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_intro_getting-started_md.7c901798.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_intro_welcome_md.69fe3324.js +0 -1
- package/doc_build/static/js/async/docs_en_guide_intro_why-module-engineering-solution_md.766afaee.js +0 -1
- package/doc_build/static/js/async/docs_en_index_md.32415ad9.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_guide_getting-started_mdx.c6631fd6.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_guide_plugin-object_mdx.0971cbdb.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_guide_setup-function_mdx.388d92b1.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_official-list_overview_md.9390ed67.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-babel_md.0528b729.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-banner_md.c14f8599.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-import_mdx.67bac7e1.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-node-polyfill_md.19819cf5.js +0 -1
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-polyfill_md.473537df.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_config_build-config_md.e52b0287.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_config_build-preset_mdx.8b874378.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_config_design-system_md.ceae6914.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_config_dev_md.033094f8.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_config_plugins_md.ab43b516.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_config_testing_md.2c1f171d.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_index_md.5df1b9d0.js +0 -1
- package/doc_build/static/js/async/docs_zh_api_plugin-api_plugin-hooks_md.9f155180.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_advance_asset_mdx.0b551e5e.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_advance_build-umd_mdx.4c0a741d.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_advance_copy_md.ff70ddd3.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_advance_external-dependency_mdx.64bae82a.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_advance_in-depth-about-build_md.d16f07b4.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_advance_in-depth-about-dev-command_md.2eabb853.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_advance_theme-config_mdx.5670e00b.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_basic_before-getting-started_md.3e23f82e.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_basic_command-preview_md.718669ed.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_basic_modify-output-product_md.bea77add.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_basic_publish-your-project_md.b0c63699.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_basic_test-your-project_mdx.b9ee0af4.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_basic_use-micro-generator_md.ad32d392.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_basic_using-storybook_mdx.2748f6f6.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_best-practices_components_mdx.e4450a3c.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_faq_build_mdx.470ca09d.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_faq_index_md.9c5738a8.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_faq_storybook_mdx.e1fb8e18.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_faq_test_mdx.d332b61f.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_intro_getting-started_md.8af35ffc.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_intro_welcome_md.6169850d.js +0 -1
- package/doc_build/static/js/async/docs_zh_guide_intro_why-module-engineering-solution_md.ff0f5ef0.js +0 -1
- package/doc_build/static/js/async/docs_zh_index_md.bc7e2f02.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_guide_getting-started_mdx.6a2c07ee.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_guide_plugin-object_mdx.9a665baa.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_guide_setup-function_mdx.a614b224.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_official-list_overview_md.bf4a7405.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-babel_md.7107a66b.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-banner_md.4443ae99.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-import_mdx.e4923a9a.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-node-polyfill_md.26c9cb0d.js +0 -1
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-polyfill_md.0bda701d.js +0 -1
- package/doc_build/static/js/defaultVendors~docs_en_api_config_build-config_md~docs_en_api_config_build-preset_mdx~docs_en~2cd1be.7070a8dd.js +0 -1
- package/doc_build/static/js/defaultVendors~docs_en_api_config_build-config_md~docs_en_api_config_build-preset_mdx~docs_en~2cd1be.7070a8dd.js.LICENSE.txt +0 -20
- package/doc_build/static/js/lib-lodash.20527186.js +0 -1
- package/doc_build/static/js/lib-polyfill.a99fdfae.js +0 -1
- package/doc_build/static/js/lib-react.87879e53.js +0 -1
- package/doc_build/static/js/lib-react.87879e53.js.LICENSE.txt +0 -29
- package/doc_build/static/js/lib-router.65b37e4a.js +0 -1
- package/doc_build/static/js/lib-router.65b37e4a.js.LICENSE.txt +0 -32
- package/doc_build/static/js/main.42725889.js +0 -1
- package/doc_build/static/search_index.en.6f4165d1.json +0 -1
- package/doc_build/static/search_index.en.8cd54797.json +0 -1
- package/doc_build/static/search_index.zh.7ed3054c.json +0 -1
- package/doc_build/static/search_index.zh.97edcc6e.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @modern-js/module-tools-docs
|
|
2
2
|
|
|
3
|
+
## 2.26.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @modern-js/doc-tools@2.26.0
|
|
8
|
+
- @modern-js/doc-plugin-auto-sidebar@2.26.0
|
|
9
|
+
|
|
10
|
+
## 2.25.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 63d8247: docs(module-tools): add faq content and slots components
|
|
15
|
+
docs(module-tools): 添加 FAQ 内容以及插槽插件
|
|
16
|
+
- @modern-js/doc-plugin-auto-sidebar@2.25.2
|
|
17
|
+
- @modern-js/doc-tools@2.25.2
|
|
18
|
+
|
|
3
19
|
## 2.25.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -36,7 +36,7 @@ export default {
|
|
|
36
36
|
};
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
After the above configuration is done, if `@common/Foo.tsx` is referenced in the code, it will map to the `<
|
|
39
|
+
After the above configuration is done, if `@common/Foo.tsx` is referenced in the code, it will map to the `<project>/src/common/Foo.tsx` path.
|
|
40
40
|
|
|
41
41
|
When the value of `alias` is defined as a function, you can accept the pre-defined alias object and modify it.
|
|
42
42
|
|
|
@@ -119,7 +119,7 @@ At this point, all static resources will be prefixed with `https://xxx/`
|
|
|
119
119
|
|
|
120
120
|
## asset.svgr
|
|
121
121
|
|
|
122
|
-
Packaged to handle svg as a React component, options reference [svgr](https://react-svgr.com/docs/options/), plus support for two configuration
|
|
122
|
+
Packaged to handle svg as a React component, options reference [svgr](https://react-svgr.com/docs/options/), plus support for two configuration options `include` and `exclude` to match the svg file to be handled
|
|
123
123
|
|
|
124
124
|
- **Type**: `boolean | object`
|
|
125
125
|
- **Default**: `false`
|
|
@@ -184,7 +184,7 @@ export default defineConfig({
|
|
|
184
184
|
});
|
|
185
185
|
```
|
|
186
186
|
|
|
187
|
-
This way the dependencies under `"dependencies"` and `"peerDependencies"` will be
|
|
187
|
+
This way the dependencies under `"dependencies"` and `"peerDependencies"` will be bundled. If you want to turn off the processing of only one of these dependencies, you can use the
|
|
188
188
|
`buildConfig.autoExternal` in the form of an object.
|
|
189
189
|
|
|
190
190
|
```js modern.config.ts
|
|
@@ -410,7 +410,7 @@ When using SWC Transform for code transformation, you can enable the `externalHe
|
|
|
410
410
|
- **Type**: `boolean`
|
|
411
411
|
- **Default**: `false`
|
|
412
412
|
|
|
413
|
-
Below is a comparison of the
|
|
413
|
+
Below is a comparison of the output file changes before and after using this configuration.
|
|
414
414
|
|
|
415
415
|
Before enable:
|
|
416
416
|
|
|
@@ -447,7 +447,7 @@ export var yourCode = function () {
|
|
|
447
447
|
|
|
448
448
|
## externals
|
|
449
449
|
|
|
450
|
-
Configure external dependencies that will not be
|
|
450
|
+
Configure external dependencies that will not be bundled into the final bundle.
|
|
451
451
|
|
|
452
452
|
- **Type**:
|
|
453
453
|
|
|
@@ -700,7 +700,7 @@ At the same time you set [style.inject](#styleinject) to `true` and you will see
|
|
|
700
700
|
[LIBUILD:ESBUILD_WARN] Ignoring this import because "other-package/dist/index.css" was marked as having no side effects
|
|
701
701
|
```
|
|
702
702
|
|
|
703
|
-
At this point, you can use this configuration
|
|
703
|
+
At this point, you can use this configuration option to manually configure the module's `"sideEffects"` to support regular and functional forms.
|
|
704
704
|
|
|
705
705
|
```js modern.config.ts
|
|
706
706
|
export default defineConfig({
|
|
@@ -718,7 +718,7 @@ After adding this configuration, the sideEffects field in package.json will no l
|
|
|
718
718
|
|
|
719
719
|
## sourceDir
|
|
720
720
|
|
|
721
|
-
Specify the source directory of the build, default is `src`, which is used to generate the corresponding
|
|
721
|
+
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`.
|
|
722
722
|
|
|
723
723
|
- **Type**: `string`
|
|
724
724
|
- **Default**: `src`
|
|
@@ -1089,7 +1089,7 @@ Reference the [Import Plugin - Notes](plugins/official-list/plugin-import.html#N
|
|
|
1089
1089
|
|
|
1090
1090
|
## umdGlobals
|
|
1091
1091
|
|
|
1092
|
-
Specify global variables for external import of umd
|
|
1092
|
+
Specify global variables for external import of umd artifacts
|
|
1093
1093
|
|
|
1094
1094
|
- **Type**: `Record<string, string>`
|
|
1095
1095
|
- **Default**: `{}`
|
|
@@ -1123,11 +1123,11 @@ export default {
|
|
|
1123
1123
|
};
|
|
1124
1124
|
```
|
|
1125
1125
|
|
|
1126
|
-
At this point the umd
|
|
1126
|
+
At this point the umd artifact will go to mount on `global.myLib`
|
|
1127
1127
|
|
|
1128
1128
|
:::tip
|
|
1129
1129
|
|
|
1130
|
-
- The module name of the umd
|
|
1130
|
+
- The module name of the umd artifact must not conflict with the global variable name.
|
|
1131
1131
|
- Module names will be converted to camelCase, e.g. `my-lib` will be converted to `myLib`, refer to [toIdentifier](https://github.com/babel/babel/blob/main/packages/babel-types/src/converters/toIdentifier.ts).
|
|
1132
1132
|
|
|
1133
1133
|
:::
|
|
@@ -70,7 +70,7 @@ export const buildConfig = [
|
|
|
70
70
|
|
|
71
71
|
### `'npm-library-with-umd'`
|
|
72
72
|
|
|
73
|
-
Used under class [NPM](https://www.npmjs.com/) package manager, and Library supports a similar pattern to [unpkg](https://unpkg.com/). Additional `umd`
|
|
73
|
+
Used under class [NPM](https://www.npmjs.com/) package manager, and Library supports a similar pattern to [unpkg](https://unpkg.com/). Additional `umd` artifacts are provided on top of the pre-defined `npm-library`.
|
|
74
74
|
|
|
75
75
|
```json package.json
|
|
76
76
|
{
|
|
@@ -115,9 +115,9 @@ export const buildConfig = [
|
|
|
115
115
|
|
|
116
116
|
### `'npm-component'`
|
|
117
117
|
|
|
118
|
-
A generic pattern for components (libraries) used under the class [NPM](https://www.npmjs.com/) package manager. Contains both `esm` and `cjs` Bundleless
|
|
118
|
+
A generic pattern for components (libraries) used under the class [NPM](https://www.npmjs.com/) package manager. Contains both `esm` and `cjs` Bundleless artifacts (for easy _[Tree shaking](https://developer.mozilla.org/zh-CN/docs/Glossary/Tree_shaking)_ optimization), as well as including a copy of the type file.
|
|
119
119
|
|
|
120
|
-
For style files included in the source code, the
|
|
120
|
+
For style files included in the source code, the artifacts provide the compiled files of the style and the source file of the style.
|
|
121
121
|
|
|
122
122
|
```json package.json
|
|
123
123
|
{
|
|
@@ -155,7 +155,7 @@ export const buildConfig = [
|
|
|
155
155
|
|
|
156
156
|
### `'npm-component-with-umd'`
|
|
157
157
|
|
|
158
|
-
Component (library) used under class [NPM](https://www.npmjs.com/) package manager, with support for class [unpkg](https://unpkg.com/) schema. Additional `umd`
|
|
158
|
+
Component (library) used under class [NPM](https://www.npmjs.com/) package manager, with support for class [unpkg](https://unpkg.com/) schema. Additional `umd` artifacts are provided on top of the pre-defined `npm-component`.
|
|
159
159
|
|
|
160
160
|
```json package.json
|
|
161
161
|
{
|
|
@@ -35,7 +35,7 @@ Project source code.
|
|
|
35
35
|
|
|
36
36
|
---
|
|
37
37
|
|
|
38
|
-
If the size of `bg.png` is less than 10 kb, then the
|
|
38
|
+
If the size of `bg.png` is less than 10 kb, then the output directory structure and file content are.
|
|
39
39
|
|
|
40
40
|
<CH.Code>
|
|
41
41
|
|
|
@@ -53,7 +53,7 @@ console.info(bg_default);
|
|
|
53
53
|
|
|
54
54
|
</CH.Code>
|
|
55
55
|
|
|
56
|
-
If the size of `bg.png` is larger than 10 kb, then the
|
|
56
|
+
If the size of `bg.png` is larger than 10 kb, then the output directory structure and file content are.
|
|
57
57
|
|
|
58
58
|
<CH.Code>
|
|
59
59
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
sidebar_position: 5
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
# Build umd
|
|
5
|
+
# Build umd artifacts
|
|
6
6
|
|
|
7
7
|
The full name of umd is **Universal Module Definition**, and JS files in this format can run in multiple runtime environments: the
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ The full name of umd is **Universal Module Definition**, and JS files in this fo
|
|
|
10
10
|
- Node.js environment: module loading based on CommonJS
|
|
11
11
|
- Other cases: mount the module on a global object.
|
|
12
12
|
|
|
13
|
-
We can therefore specify the build
|
|
13
|
+
We can therefore specify the build artifacts of the project as an umd artifact in the following way:
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
export default defineConfig({
|
|
@@ -20,10 +20,10 @@ export default defineConfig({
|
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
## Third-party dependency handling for umd
|
|
23
|
+
## Third-party dependency handling for umd artifacts
|
|
24
24
|
|
|
25
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
|
-
So when building umd
|
|
26
|
+
So when building umd artifacts, we can also use it like this:
|
|
27
27
|
|
|
28
28
|
<CH.Spotlight>
|
|
29
29
|
|
|
@@ -74,7 +74,7 @@ console.info(React);
|
|
|
74
74
|
|
|
75
75
|
---
|
|
76
76
|
|
|
77
|
-
The `react` code is not
|
|
77
|
+
The `react` code is not bundled into the artifact at this point.
|
|
78
78
|
|
|
79
79
|
```js dist/index.js focus=1:7
|
|
80
80
|
(function (global, factory) {
|
|
@@ -162,7 +162,7 @@ console.info(React);
|
|
|
162
162
|
|
|
163
163
|
---
|
|
164
164
|
|
|
165
|
-
At this point we will see the
|
|
165
|
+
At this point we will see the output code like this.
|
|
166
166
|
|
|
167
167
|
```js dist/index.js focus=12:18
|
|
168
168
|
(function (global, factory) {
|
|
@@ -193,7 +193,7 @@ The project can then run in the browser and use the `React` variables that exist
|
|
|
193
193
|
|
|
194
194
|
## Changing the name of a global variable in a project
|
|
195
195
|
|
|
196
|
-
When we package the following code into an umd
|
|
196
|
+
When we package the following code into an umd artifact and run it in the browser, we can use the module via `window.index`.
|
|
197
197
|
|
|
198
198
|
```ts ./src/index.ts
|
|
199
199
|
export default () => {
|
|
@@ -201,7 +201,7 @@ export default () => {
|
|
|
201
201
|
};
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
-
** By default, the name of the source file is used as the name of the module's global variable in the browser. **For the above example, the
|
|
204
|
+
** By default, the name of the source file is used as the name of the module's global variable in the browser. **For the above example, the artifact would read as follows:
|
|
205
205
|
|
|
206
206
|
```js ./dist/index.js focus=9:9
|
|
207
207
|
(function (global, factory) {
|
|
@@ -231,7 +231,7 @@ export default defineConfig({
|
|
|
231
231
|
});
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
The
|
|
234
|
+
The build artifact at this point are:
|
|
235
235
|
|
|
236
236
|
```js ./dist/index.js focus=9:9
|
|
237
237
|
(function (global, factory) {
|
|
@@ -4,7 +4,7 @@ sidebar_position: 3
|
|
|
4
4
|
|
|
5
5
|
# Use the Copy Tools
|
|
6
6
|
|
|
7
|
-
The Module Project provides the Copy utility for copying already existing individual files or entire directories into the
|
|
7
|
+
The Module Project provides the Copy utility for copying already existing individual files or entire directories into the output directory. Next we learn how to use it.
|
|
8
8
|
|
|
9
9
|
## Understanding the Copy API
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ In addition to `"dependencies"`, [`"peerDependencies"`](/en/guide/basic/before-g
|
|
|
19
19
|
|
|
20
20
|
## Default handling of third-party dependencies
|
|
21
21
|
|
|
22
|
-
By default, third-party dependencies under `"dependencies"` and `"peerDependencies"` are not
|
|
22
|
+
By default, third-party dependencies under `"dependencies"` and `"peerDependencies"` are not bundled in the module project\*\*.
|
|
23
23
|
|
|
24
24
|
This is because when the npm package is installed, its `"dependencies"` will also be installed. By not packaging `"dependencies"`, you can reduce the size of the package product.
|
|
25
25
|
|
|
@@ -66,7 +66,7 @@ console.info(React);
|
|
|
66
66
|
|
|
67
67
|
---
|
|
68
68
|
|
|
69
|
-
The `react` code is not
|
|
69
|
+
The `react` code is not bundled into the artifact at this point.
|
|
70
70
|
|
|
71
71
|
```js dist/index.js
|
|
72
72
|
import React from 'react';
|
|
@@ -4,7 +4,7 @@ sidebar_position: 1
|
|
|
4
4
|
|
|
5
5
|
# In-depth understanding of build
|
|
6
6
|
|
|
7
|
-
In the "Basic Usage" section, we already knew that you can modify the output
|
|
7
|
+
In the "Basic Usage" section, we already knew that you can modify the output files of a project through the `buildConfig` configuration. `buildConfig` not only describes some of the features of the product, but also provides some functionality for building the product.
|
|
8
8
|
|
|
9
9
|
:::tip
|
|
10
10
|
If you are not familiar with `buildConfig`, please read [modify-output-product](/en/guide/basic/modify-output-product).
|
|
@@ -20,11 +20,11 @@ So first let's understand Bundle and Bundleless.
|
|
|
20
20
|
|
|
21
21
|
A Bundle is a package of build products, which may be a single file or multiple files based on a certain [code splitting strategy](https://esbuild.github.io/api/#splitting).
|
|
22
22
|
|
|
23
|
-
Bundleless, on the other hand, means that each source file is compiled and built separately, but not
|
|
23
|
+
Bundleless, on the other hand, means that each source file is compiled and built separately, but not bundled together. Each output file can be found with its corresponding source code file. The process of **Bundleless build can also be understood as the process of code conversion of source files only**.
|
|
24
24
|
|
|
25
25
|
They have their own benefits.
|
|
26
26
|
|
|
27
|
-
- Bundle can reduce the size of build
|
|
27
|
+
- Bundle can reduce the size of build artifacts and also pre-package dependencies to reduce the size of installed dependencies. Packaging libraries in advance can speed up application project builds.
|
|
28
28
|
- Bundleless maintains the original file structure and is more conducive to debugging and tree shaking.
|
|
29
29
|
|
|
30
30
|
:::warning
|
|
@@ -48,7 +48,7 @@ We know from the defaults: **Bundle builds can generally specify a file path as
|
|
|
48
48
|
|
|
49
49
|
#### Object type of `input`
|
|
50
50
|
|
|
51
|
-
In addition to setting `input` to an array, you can also set it to an object during the Bundle build process. **By using the object form, we can modify the name of the file that the build
|
|
51
|
+
In addition to setting `input` to an array, you can also set it to an object during the Bundle build process. **By using the object form, we can modify the name of the file that the build artifacts outputs**. So for the following example, `. /src/index.ts` corresponds to the path of the build artifacts file as `. /dist/main.js`.
|
|
52
52
|
|
|
53
53
|
```js modern.config.ts
|
|
54
54
|
import { defineConfig } from '@modern-js/module-tools';
|
|
@@ -103,9 +103,9 @@ The build speed is generally improved by closing the type file.
|
|
|
103
103
|
|
|
104
104
|
With `buildType: 'bundleless'`, type files are generated using the project's `tsc` command to complete production.
|
|
105
105
|
|
|
106
|
-
The **
|
|
106
|
+
The **Module Tools also supports bundling of type files**, although care needs to be taken when using this feature.
|
|
107
107
|
|
|
108
|
-
- Some third-party dependencies have incorrect syntax that can cause the
|
|
108
|
+
- 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).
|
|
109
109
|
- 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"}`.
|
|
110
110
|
|
|
111
111
|
#### Alias Conversion
|
|
@@ -116,7 +116,7 @@ During the Bundleless build process, if an alias appears in the source code, e.g
|
|
|
116
116
|
import utils from '@common/utils';
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Normally,
|
|
119
|
+
Normally, the type files generated with `tsc` will also contain these aliases. However, Module Tools will convert the aliases in the type file generated by `tsc` to:
|
|
120
120
|
|
|
121
121
|
- Alias conversion is possible for code of the form `import '@common/utils'` or `import utils from '@common/utils'`.
|
|
122
122
|
- Aliasing is possible for code of the form `export { utils } from '@common/utils'`.
|
|
@@ -133,7 +133,7 @@ General usage:
|
|
|
133
133
|
import { defineConfig } from '@modern-js/module-tools';
|
|
134
134
|
|
|
135
135
|
export default defineConfig({
|
|
136
|
-
// The output path of the
|
|
136
|
+
// The output path of the bundled type file at this point is `./dist/types`
|
|
137
137
|
buildConfig: {
|
|
138
138
|
buildType: 'bundle',
|
|
139
139
|
dts: {
|
|
@@ -151,7 +151,7 @@ For the use of `dts.only`:
|
|
|
151
151
|
import { defineConfig } from '@modern-js/module-tools';
|
|
152
152
|
|
|
153
153
|
export default defineConfig({
|
|
154
|
-
// At this moment the type file is not
|
|
154
|
+
// At this moment the type file is not bundled and the output path is `./dist/types`
|
|
155
155
|
buildConfig: [
|
|
156
156
|
{
|
|
157
157
|
buildType: 'bundle',
|
|
@@ -239,8 +239,8 @@ declare const YOUR_ADD_GLOBAL_VAR;
|
|
|
239
239
|
|
|
240
240
|
When the `modern build` command is executed, the
|
|
241
241
|
|
|
242
|
-
- Clear the
|
|
243
|
-
- Compile `js/ts` source code to generate the JS build
|
|
242
|
+
- Clear the output directory according to `buildConfig.outDir`.
|
|
243
|
+
- Compile `js/ts` source code to generate the JS build artifacts for Bundle/Bundleless.
|
|
244
244
|
- Generate Bundle/Bundleless type files using `tsc`.
|
|
245
245
|
- Handle Copy tasks.
|
|
246
246
|
|
|
@@ -18,7 +18,7 @@ In addition to the `dev` command, you can also start a debugging tool or task di
|
|
|
18
18
|
|
|
19
19
|
## Extending the dev command
|
|
20
20
|
|
|
21
|
-
If you need to extend the dev command, or rather provide your own Module Tools debugging tool
|
|
21
|
+
If you need to extend the dev command, or rather provide your own Module Tools debugging tool plugin, then you will need to know the following first.
|
|
22
22
|
|
|
23
23
|
* [Development of plugins](plugins/guide/getting-started)
|
|
24
24
|
* [Debugging Tools Plugin API](/api/plugin-api/plugin-hooks#调试钩子)
|
|
@@ -6,7 +6,7 @@ sidebar_position: 1
|
|
|
6
6
|
|
|
7
7
|
## Environment preparation
|
|
8
8
|
|
|
9
|
-
In order to use the Modern.js
|
|
9
|
+
In order to use the Modern.js Module Tools, you first need [NodeJS](https://nodejs.org/zh/) engine, we recommend the latest [LTS version](https://github.com/nodejs/Release), and make sure the Node version is **>=14.18.0**. because non-stable NodeJS releases frequently have bugs. You might consider installing via [nvm-windows](https://github.com/coreybutler/nvm-windows) and [nvm](https://github.com/nvm-sh/nvm) (Mac / Linux), so you can easily switch to different NodeJS versions that might be required for different projects that you work on.
|
|
10
10
|
|
|
11
11
|
## Getting Started with npm
|
|
12
12
|
|
|
@@ -19,7 +19,7 @@ Options:
|
|
|
19
19
|
". /tsconfig.json")
|
|
20
20
|
--platform [platform] Build products for all or specified platforms
|
|
21
21
|
--no-dts disables DTS type file generation and type checking
|
|
22
|
-
--no-clear disables automatic clearing of
|
|
22
|
+
--no-clear disables automatic clearing of output directories
|
|
23
23
|
-h, --help Show information about the current command
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -28,12 +28,12 @@ When you want to start a project build, you can execute the `modern build` comma
|
|
|
28
28
|
- When wanting to start a build in watch mode, use the `--watch` option.
|
|
29
29
|
- When you want to specify the path to the TypeScript configuration file read by the project build, use `-build --tsconfig . /path/config.json` option. This option overrides all [`buildConfig`](/api/config/build-config) configurations in [`dts.tsconfigPath`](/api/config/build-config).
|
|
30
30
|
- The `-no-dts` option can be used when the DTS type file generation and type checking behavior of the project needs to be turned off. **Note: The generation of type files depends on the results of type checking. If type checking is turned off, then type files will not be generated either**.
|
|
31
|
-
- The `--no-clear` option can be used when the automatic clearing of the
|
|
31
|
+
- The `--no-clear` option can be used when the automatic clearing of the output directory needs to be turned off.
|
|
32
32
|
|
|
33
|
-
In addition to the above, module projects also support `platform` build mode, which can be used to perform build tasks for other tools. For example, it is currently officially supported to start a Storybook build task to generate Storybook
|
|
33
|
+
In addition to the above, module projects also support `platform` build mode, which can be used to perform build tasks for other tools. For example, it is currently officially supported to start a Storybook build task to generate Storybook artifacts by executing the `modern build --platform` or `modern build --platform storybook` commands after installing the `@modern-js/plugin-storybook` plugin.
|
|
34
34
|
|
|
35
35
|
:::tip
|
|
36
|
-
When executing a Storybook build, if you need to read the build
|
|
36
|
+
When executing a Storybook build, if you need to read the build artifacts of the project. Then **don't forget to execute the `modern build` command to ensure the existence of the project's build artifacts before executing the `modern build --platform` command to start the Storybook build**.
|
|
37
37
|
:::
|
|
38
38
|
|
|
39
39
|
## `modern new`
|
|
@@ -76,7 +76,7 @@ Commands:
|
|
|
76
76
|
[dev-tools-subCommand]
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
The
|
|
79
|
+
The Module Tools provides the ability to use debugging tools, which can be started with the `modern dev` command. Note, however, that no debugging-related plugins are provided by default, so executing `modern dev` will prompt: _"No dev tools found available "_.
|
|
80
80
|
|
|
81
81
|
The officially supported debugging tool is [Storybook](https://storybook.js.org/), so you can run `modern dev` or `modern dev storybook` to execute it after you run `modern new` to enable it.
|
|
82
82
|
|
|
@@ -6,7 +6,7 @@ sidebar_position: 3
|
|
|
6
6
|
|
|
7
7
|
## Default output products
|
|
8
8
|
|
|
9
|
-
When you use the `modern build` command in an initialized project, Module Tools will generate corresponding build
|
|
9
|
+
When you use the `modern build` command in an initialized project, Module Tools will generate corresponding build artifacts based on the current configuration.
|
|
10
10
|
|
|
11
11
|
The default configuration is as follows:
|
|
12
12
|
|
|
@@ -21,11 +21,11 @@ export default defineConfig({
|
|
|
21
21
|
});
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
**The default
|
|
24
|
+
**The default output files has the following characteristics**.
|
|
25
25
|
|
|
26
26
|
- will generate [CommonJS](https://nodejs.org/api/modules.html#modules-commonjs-modules) and [ESM](https://nodejs.org/api/esm.html#modules- ecmascript-modules).
|
|
27
27
|
- The code syntax is supported up to `ES6` , and more advanced syntax will be converted.
|
|
28
|
-
- All code is
|
|
28
|
+
- All code is bundled into one file, i.e. **bundle** processing is performed.
|
|
29
29
|
- The output root directory is the `dist` directory under the project, and the type file output directory is `dist/types`.
|
|
30
30
|
|
|
31
31
|
You may have the following questions when you see this.
|
|
@@ -43,17 +43,17 @@ The `buildPreset` represents one or more sets of build-related configurations pr
|
|
|
43
43
|
|
|
44
44
|
The value of a **build preset can be in the form of a string**, so a build preset of this form is called a preset string.
|
|
45
45
|
|
|
46
|
-
The
|
|
46
|
+
The Module Tools provides generic build preset strings and corresponding variants, depending on the generic scenario in which the npm package is used. All currently supported preset strings can be viewed via the [BuildPreset API](/api/config/build-preset). Here is an explanation about the relationship between **generic preset strings and variants**.
|
|
47
47
|
|
|
48
|
-
Among the generic preset strings, `"npm-library"` can be used in the scenario of developing npm packages of the library type, which is suitable for most common module type projects. When `"npm-library"` is set, the output
|
|
48
|
+
Among the generic preset strings, `"npm-library"` can be used in the scenario of developing npm packages of the library type, which is suitable for most common module type projects. When `"npm-library"` is set, the output files of the project will have the following characteristics.
|
|
49
49
|
|
|
50
|
-
- In the `dist/lib` directory you will get code formatted as `cjs`, syntax supported up to `es6` and
|
|
51
|
-
- In the `dist/es` directory, you get code in the format `esm`, with syntax support up to `es6` and after
|
|
50
|
+
- In the `dist/lib` directory you will get code formatted as `cjs`, syntax supported up to `es6` and bundled.
|
|
51
|
+
- In the `dist/es` directory, you get code in the format `esm`, with syntax support up to `es6` and after bundling.
|
|
52
52
|
- In the `dist/types` directory, you get the type files. If it is not a TypeScript project, there is no such directory.
|
|
53
53
|
|
|
54
54
|
The default string `"npm-library"` is a variant of the original product with a modified **code syntax support** feature and a string naming change to `"npm-library-[es5 | es2016.... . es2020 | esnext]"`.
|
|
55
55
|
|
|
56
|
-
For example, if the output
|
|
56
|
+
For example, if the output file is based on the preset string `"npm-library"` and the syntax supported by the output code is changed to `es5`, then simply changing `"npm-library"` to `"npm-library-es5"` would be sufficient.
|
|
57
57
|
|
|
58
58
|
### Build pre-defined function forms
|
|
59
59
|
|
|
@@ -88,26 +88,26 @@ In addition, under the `preset` object, it not only includes `NPM_LIBRARY`, but
|
|
|
88
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
89
|
:::
|
|
90
90
|
|
|
91
|
-
So what is the `buildConfig` object here? What is the basis for the build
|
|
91
|
+
So what is the `buildConfig` object here? What is the basis for the build artifacts feature mentioned before?
|
|
92
92
|
|
|
93
93
|
Let's explain next.
|
|
94
94
|
|
|
95
95
|
## Build configuration (object)
|
|
96
96
|
|
|
97
|
-
**`buildConfig` is a configuration option that describes how to compile and generate build
|
|
97
|
+
**`buildConfig` is a configuration option that describes how to compile and generate build artifacts**. 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 artifacts have, but also contains some features needed to build products. The following is a brief list from a classification point of view.
|
|
98
98
|
|
|
99
|
-
**The basic attributes of a build
|
|
99
|
+
**The basic attributes of a build artifacts include:**
|
|
100
100
|
|
|
101
|
-
- Whether the
|
|
101
|
+
- Whether the artifact is bundled or not: the corresponding API is [`buildConfig.buildType`](/api/config/build-config#buildtype).
|
|
102
102
|
- Product support for syntax: the corresponding API is [`buildConfig.target`](/api/config/build-config#target).
|
|
103
103
|
- Output format: the corresponding API is [`buildConfig.format`](/api/config/build-config#format).
|
|
104
104
|
- How the output type file is handled: the corresponding API is [`buildConfig.dts`](/api/config/build-config#dts).
|
|
105
|
-
- How the sourceMap of the
|
|
105
|
+
- How the sourceMap of the artifact is handled: the corresponding API is [`buildConfig.sourceMap`](/api/config/build-config#sourcemap).
|
|
106
106
|
- The input (or source file) corresponding to the output: the corresponding API is [`buildConfig.input`](/api/config/build-config#input).
|
|
107
|
-
- The directory of the output of the
|
|
107
|
+
- The directory of the output of the artifact: the corresponding API is [`buildConfig.outDir`](/api/config/build-config#outDir).
|
|
108
108
|
- Build source directory: the corresponding API is [`buildConfig.sourceDir`](/api/config/build-config#sourcedir).
|
|
109
109
|
|
|
110
|
-
**Common functions required for build
|
|
110
|
+
**Common functions required for build artifacts include:**
|
|
111
111
|
|
|
112
112
|
- Alias: The corresponding API is [`buildConfig.alias`](/api/config/build-config#alias).
|
|
113
113
|
- Static resource handling: the corresponding API is [`buildConfig.asset`](/api/config/build-config#asset).
|
|
@@ -122,7 +122,7 @@ Let's explain next.
|
|
|
122
122
|
|
|
123
123
|
- Product code compression: The corresponding API is [`buildConfig.minify`](/api/config/build-config#minify).
|
|
124
124
|
- Code splitting: [`buildConfig.splitting`](/api/config/build-config#splitting)
|
|
125
|
-
- Specify whether the build
|
|
125
|
+
- Specify whether the build artifacts is for the NodeJS environment or the browser environment: the corresponding API is [`buildConfig.platform`](/api/config/build-config#platform).
|
|
126
126
|
- umd product-related.
|
|
127
127
|
- Specifies the global variables imported externally to the umd product: the corresponding API is [`buildConfig.umdGlobals`](/api/config/build-config#umdglobals).
|
|
128
128
|
- Specify the module name of the umd product: the corresponding API is [`buildConfig.umdModuleName`](/api/config/build-config#umdmodulename).
|
|
@@ -135,7 +135,7 @@ In addition to the above categories, frequently asked questions and best practic
|
|
|
135
135
|
- [`buildConfig.define` Different ways to use it for different scenarios.](/guide/advance/in-depth-about-build#buildconfigdefine - How to use it for different scenarios)
|
|
136
136
|
- [How to handle third-party dependencies?](/guide/advance/external-dependency)
|
|
137
137
|
- [How to use copy?](/guide/advance/copy)
|
|
138
|
-
- How do I build umd
|
|
138
|
+
- How do I build umd artifacts? (/guide/advance/build-umd# sets the global variable name of the project)
|
|
139
139
|
- [The capabilities currently supported by static resources.](/guide/advance/asset)
|
|
140
140
|
|
|
141
141
|
## When to use `buildConfig`
|
|
@@ -161,4 +161,4 @@ Since both 'buildConfig' and 'buildPreset' are present, only the 'buildConfig' c
|
|
|
161
161
|
|
|
162
162
|
The set or sets of build-related configurations represented by `buildPreset` are composed of `buildConfig`, **which can be used to customize output products** when the current project needs cannot be met using `buildPreset`.
|
|
163
163
|
|
|
164
|
-
The process of using `buildConfig` is the process of thinking about **what kind of build
|
|
164
|
+
The process of using `buildConfig` is the process of thinking about **what kind of build artifacts to get**.
|
|
@@ -197,4 +197,4 @@ For the `modern build --platform` command you can see.
|
|
|
197
197
|
|
|
198
198
|
- [`modern build`](/en/guide/basic/command-preview#modern-build)
|
|
199
199
|
|
|
200
|
-
After the build is complete, you can see the build
|
|
200
|
+
After the build is complete, you can see the build artifacts files in the `dist/storybook-static` directory.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Developing Components
|
|
2
2
|
|
|
3
|
-
This chapter will describe how to develop component projects using the
|
|
3
|
+
This chapter will describe how to develop component projects using the Module Tools.
|
|
4
4
|
|
|
5
5
|
## Initialize the project
|
|
6
6
|
|
|
@@ -176,7 +176,7 @@ While importing source code for debugging is also supported, debugging using pro
|
|
|
176
176
|
|
|
177
177
|
Debugging with source code has a limitation: some configurations are not equivalent in Storybook and in the original build support.
|
|
178
178
|
|
|
179
|
-
**This is why debugging with the
|
|
179
|
+
**This is why debugging with the output code is recommended**.
|
|
180
180
|
|
|
181
181
|
```tsx ./stories/index.stories.tsx
|
|
182
182
|
import Component from '../src';
|
|
@@ -615,11 +615,11 @@ export default () => {
|
|
|
615
615
|
};
|
|
616
616
|
```
|
|
617
617
|
|
|
618
|
-
In Bundle mode, third-party dependencies are
|
|
618
|
+
In Bundle mode, third-party dependencies are bundled in.
|
|
619
619
|
|
|
620
|
-
For styles, a separate
|
|
620
|
+
For styles, a separate output file is generated, and there is no code related to importing styles in the JS output files.
|
|
621
621
|
|
|
622
|
-
If you need to inject styles into JS
|
|
622
|
+
If you need to inject styles into JS output files, you can enable the [`style.inject`](/en/api/config/build-config#styleinject) option.
|
|
623
623
|
|
|
624
624
|
<CH.Code>
|
|
625
625
|
```css ./dist/es/index.css
|
|
@@ -703,7 +703,7 @@ export {
|
|
|
703
703
|
```
|
|
704
704
|
</CH.Code>
|
|
705
705
|
|
|
706
|
-
In Bundleless mode, no third-party dependencies are
|
|
706
|
+
In Bundleless mode, no third-party dependencies are bundled, and no style artifacts are generated at this time.
|
|
707
707
|
|
|
708
708
|
```js ./dist/es/index.js
|
|
709
709
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -753,7 +753,7 @@ export default () => {
|
|
|
753
753
|
|
|
754
754
|
## Configuring build products
|
|
755
755
|
|
|
756
|
-
Based on most scenarios of component project usage, **it is recommended to use the `npm-component` build preset**. This preset yields a
|
|
756
|
+
Based on most scenarios of component project usage, **it is recommended to use the `npm-component` build preset**. This preset yields a output directory structure of
|
|
757
757
|
|
|
758
758
|
```bash
|
|
759
759
|
.
|
|
@@ -763,8 +763,8 @@ Based on most scenarios of component project usage, **it is recommended to use t
|
|
|
763
763
|
│ └── types
|
|
764
764
|
```
|
|
765
765
|
|
|
766
|
-
- `. /dist/es`: Contains bundleless
|
|
767
|
-
- `. /dist/lib`: Contains bundleless
|
|
766
|
+
- `. /dist/es`: Contains bundleless artifacts in ES modules format that support the es6 syntax.
|
|
767
|
+
- `. /dist/lib`: Contains bundleless artifacts in CommonJS format with support for es6 syntax.
|
|
768
768
|
- `. /dist/types`: Contains the types file.
|
|
769
769
|
|
|
770
770
|
The [`buildPreset`](/en/api/config/build-preset) can be configured manually if there is a requirement to use syntax support, and supports modifying the supported syntax by adding a suffix to `npm-component`.
|
|
@@ -775,7 +775,7 @@ export default defineConfig({
|
|
|
775
775
|
});
|
|
776
776
|
```
|
|
777
777
|
|
|
778
|
-
If you have special needs for the build
|
|
778
|
+
If you have special needs for the build artifacts directory structure, you can use the [`buildConfig` API](/en/api/config/build-config), which can be used by the following documentation.
|
|
779
779
|
|
|
780
780
|
- [modify-output-product](/en/guide/basic/modify-output-product#build-configuration-object)
|
|
781
781
|
- [in-depth-about-build](/en/guide/advance/in-depth-about-build)
|
|
@@ -118,7 +118,7 @@ If you import a cjs product from a third-party npm package, the resulting produc
|
|
|
118
118
|
|
|
119
119
|
#### Solution
|
|
120
120
|
|
|
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://
|
|
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
|
|
@@ -6,7 +6,7 @@ sidebar_position: 1
|
|
|
6
6
|
|
|
7
7
|
Module Tools is a modules engineering solution for Modern.js, as well as a core dependency. It allows developers to build, debug, and publish module type project more easily. A module type project can mostly be thought of as an npm package type project, which may be a component, component library or tool library project.
|
|
8
8
|
|
|
9
|
-
If you are planning to develop a project of the npm package type, then you came to the right place! Modern.js provides a professional
|
|
9
|
+
If you are planning to develop a project of the npm package type, then you came to the right place! Modern.js provides a professional Module Tools. It gives you:
|
|
10
10
|
|
|
11
11
|
- **Simple project initialization**: simply execute the `npx @modern-js/create project-dir` command, followed by a few interactive questions, to create a complete module type project. The created project also supports the choice of two package managers, [**pnpm**](https://pnpm.io/) and [**Yarn**](https://classic.yarnpkg.com/).
|
|
12
12
|
- **Code formatting**: In a module project, you can execute `modern lint` to format the code. The initialized module project includes the [ESLint](https://eslint.org/docs/latest/user-guide/core-concepts#what-is-eslint) ruleset for Modern.js for most scenarios.
|
|
@@ -14,5 +14,5 @@ If you are planning to develop a project of the npm package type, then you came
|
|
|
14
14
|
- **Storybook debugging tools**: Module Tools provides [Storybook](https://storybook.js.org/) debugging tools for debugging module projects. After installing the Storybook plugin for Module Tools, you can start it with the `modern dev storybook` command. You can use Storybook not only for debugging components, but also for other types of modules.
|
|
15
15
|
- **Testing capabilities with Jest**: When you need to test a module, you can use the `modern test` command of Module Tools, which not only integrates with [Jest](https://jestjs.io/), but also provides an API for configuring [Jest](https://jestjs.io/docs/configuration).
|
|
16
16
|
- **Versioning based on Changesets**: When you need to record changes to a project, you can use the `modern change` command to generate a Markdown file containing the changes; when you need to upgrade a project, you can use the `modern bump` command to analyze and upgrade the version through the Markdown file; when you need to release a project, you can use the `modern release` command to release the project; Module Tools implements these commands based on [Changesets](https://github.com/changesets/changesets).
|
|
17
|
-
- **Extensible
|
|
17
|
+
- **Extensible plugin mechanism**: Want to integrate additional debugging tools for your project? Or maybe you want to do some extra processing during the build process, Module Tools provides a plugin mechanism and plugin hooks that cover both the `dev` command and the `build` command process. You can use them to extend the capabilities of your project.
|
|
18
18
|
- **Lots more!** Module Tools will continue to optimize its build and debug features in the future. If there are important issues to be solved in module project building, or if a mainstream module project debugging tool or pattern emerges, then they will probably be supported by Module Tools.
|
|
@@ -80,5 +80,5 @@ With the above example, we learned the following things.
|
|
|
80
80
|
|
|
81
81
|
In addition to the above, we also need to understand.
|
|
82
82
|
|
|
83
|
-
- [plugin objects, type definitions and recommended configuration
|
|
83
|
+
- [plugin objects, type definitions and recommended configuration options](/en/plugins/guide/plugin-object)
|
|
84
84
|
- [setup functions, `api` object parameters, lifecycle hooks](/en/plugins/guide/setup-function)
|