@modern-js/module-tools-docs 2.25.0 → 2.25.2-beta.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 +7 -0
- package/doc_build/api/config/build-config.html +522 -0
- package/doc_build/api/config/build-preset.html +71 -0
- package/doc_build/api/config/design-system.html +113 -0
- package/doc_build/api/config/dev.html +40 -0
- package/doc_build/api/config/plugins.html +31 -0
- package/doc_build/api/config/testing.html +31 -0
- package/doc_build/api/index.html +11 -0
- package/doc_build/api/plugin-api/plugin-hooks.html +122 -0
- package/doc_build/components/faq-build-exception.html +11 -0
- package/doc_build/components/faq-build-other.html +11 -0
- package/doc_build/components/faq-build-product.html +11 -0
- package/doc_build/components/faq-storybook.html +11 -0
- package/doc_build/components/faq-test.html +11 -0
- package/doc_build/en/api/config/build-config.html +443 -0
- package/doc_build/en/api/config/build-preset.html +71 -0
- package/doc_build/en/api/config/design-system.html +127 -0
- package/doc_build/en/api/config/dev.html +40 -0
- package/doc_build/en/api/config/plugins.html +31 -0
- package/doc_build/en/api/config/testing.html +31 -0
- package/doc_build/en/api/index.html +11 -0
- package/doc_build/en/api/plugin-api/plugin-hooks.html +122 -0
- package/doc_build/en/components/faq-build-exception.html +11 -0
- package/doc_build/en/components/faq-build-other.html +11 -0
- package/doc_build/en/components/faq-build-product.html +11 -0
- package/doc_build/en/components/faq-storybook.html +11 -0
- package/doc_build/en/components/faq-test.html +11 -0
- package/doc_build/en/guide/advance/asset.html +31 -0
- package/doc_build/en/guide/advance/build-umd.html +42 -0
- package/doc_build/en/guide/advance/copy.html +52 -0
- package/doc_build/en/guide/advance/external-dependency.html +32 -0
- package/doc_build/en/guide/advance/in-depth-about-build.html +123 -0
- package/doc_build/en/guide/advance/in-depth-about-dev-command.html +32 -0
- package/doc_build/en/guide/advance/theme-config.html +39 -0
- package/doc_build/en/guide/basic/before-getting-started.html +97 -0
- package/doc_build/en/guide/basic/command-preview.html +73 -0
- package/doc_build/en/guide/basic/modify-output-product.html +113 -0
- package/doc_build/en/guide/basic/publish-your-project.html +60 -0
- package/doc_build/en/guide/basic/test-your-project.html +41 -0
- package/doc_build/en/guide/basic/use-micro-generator.html +47 -0
- package/doc_build/en/guide/basic/using-storybook.html +76 -0
- package/doc_build/en/guide/best-practices/components.html +121 -0
- package/doc_build/en/guide/faq/build.html +91 -0
- package/doc_build/en/guide/faq/index.html +17 -0
- package/doc_build/en/guide/faq/storybook.html +53 -0
- package/doc_build/en/guide/faq/test.html +16 -0
- package/doc_build/en/guide/intro/getting-started.html +53 -0
- package/doc_build/en/guide/intro/welcome.html +23 -0
- package/doc_build/en/guide/intro/why-module-engineering-solution.html +19 -0
- package/doc_build/en/index.html +11 -0
- package/doc_build/en/plugins/guide/getting-started.html +25 -0
- package/doc_build/en/plugins/guide/plugin-object.html +24 -0
- package/doc_build/en/plugins/guide/setup-function.html +40 -0
- package/doc_build/en/plugins/official-list/overview.html +19 -0
- package/doc_build/en/plugins/official-list/plugin-babel.html +23 -0
- package/doc_build/en/plugins/official-list/plugin-banner.html +40 -0
- package/doc_build/en/plugins/official-list/plugin-import.html +44 -0
- package/doc_build/en/plugins/official-list/plugin-node-polyfill.html +88 -0
- package/doc_build/en/plugins/official-list/plugin-polyfill.html +28 -0
- package/doc_build/guide/advance/asset.html +31 -0
- package/doc_build/guide/advance/build-umd.html +42 -0
- package/doc_build/guide/advance/copy.html +52 -0
- package/doc_build/guide/advance/external-dependency.html +31 -0
- package/doc_build/guide/advance/in-depth-about-build.html +123 -0
- package/doc_build/guide/advance/in-depth-about-dev-command.html +32 -0
- package/doc_build/guide/advance/theme-config.html +38 -0
- package/doc_build/guide/basic/before-getting-started.html +97 -0
- package/doc_build/guide/basic/command-preview.html +73 -0
- package/doc_build/guide/basic/modify-output-product.html +110 -0
- package/doc_build/guide/basic/publish-your-project.html +62 -0
- package/doc_build/guide/basic/test-your-project.html +43 -0
- package/doc_build/guide/basic/use-micro-generator.html +45 -0
- package/doc_build/guide/basic/using-storybook.html +74 -0
- package/doc_build/guide/best-practices/components.html +121 -0
- package/doc_build/guide/faq/build.html +91 -0
- package/doc_build/guide/faq/index.html +17 -0
- package/doc_build/guide/faq/storybook.html +53 -0
- package/doc_build/guide/faq/test.html +16 -0
- package/doc_build/guide/intro/getting-started.html +50 -0
- package/doc_build/guide/intro/welcome.html +23 -0
- package/doc_build/guide/intro/why-module-engineering-solution.html +19 -0
- package/doc_build/index.html +11 -0
- package/doc_build/plugins/guide/getting-started.html +25 -0
- package/doc_build/plugins/guide/plugin-object.html +24 -0
- package/doc_build/plugins/guide/setup-function.html +40 -0
- package/doc_build/plugins/official-list/overview.html +19 -0
- package/doc_build/plugins/official-list/plugin-babel.html +23 -0
- package/doc_build/plugins/official-list/plugin-banner.html +40 -0
- package/doc_build/plugins/official-list/plugin-import.html +44 -0
- package/doc_build/plugins/official-list/plugin-node-polyfill.html +88 -0
- package/doc_build/plugins/official-list/plugin-polyfill.html +28 -0
- package/doc_build/route.json +10 -0
- package/doc_build/ssr/bundles/main.js +30 -0
- package/doc_build/ssr/bundles/main.js.LICENSE.txt +103 -0
- 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 +1 -0
- package/doc_build/static/css/main.1e1c5ea3.css +17 -0
- 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 +1 -0
- package/doc_build/static/js/async/docs_en_api_config_build-config_md.47c13184.js +1 -0
- package/doc_build/static/js/async/docs_en_api_config_build-preset_mdx.240d175b.js +1 -0
- package/doc_build/static/js/async/docs_en_api_config_design-system_md.b2ec1ff7.js +1 -0
- package/doc_build/static/js/async/docs_en_api_config_dev_md.6ad208aa.js +1 -0
- package/doc_build/static/js/async/docs_en_api_config_plugins_md.da21c1a9.js +1 -0
- package/doc_build/static/js/async/docs_en_api_config_testing_md.5655d56b.js +1 -0
- package/doc_build/static/js/async/docs_en_api_index_md.b332bf64.js +1 -0
- package/doc_build/static/js/async/docs_en_api_plugin-api_plugin-hooks_md.b0f73e0d.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_advance_asset_mdx.d302e90c.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_advance_build-umd_mdx.554fa073.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_advance_copy_md.78b33f73.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_advance_external-dependency_mdx.507e4091.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_advance_in-depth-about-build_md.207e8b25.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_advance_in-depth-about-dev-command_md.72d6b6fc.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_advance_theme-config_mdx.168a5eec.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_basic_before-getting-started_md.a00933ab.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_basic_command-preview_md.5e63d7ad.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_basic_modify-output-product_md.abd250e1.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_basic_publish-your-project_md.3b098b03.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_basic_test-your-project_mdx.b86e9b69.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_basic_use-micro-generator_md.e03b16c8.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_basic_using-storybook_mdx.32e9b389.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_best-practices_components_mdx.a56e369b.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_faq_build_mdx.81c243c7.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_faq_index_md.85367f4a.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_faq_storybook_mdx.d6b26cfd.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_faq_test_mdx.a7a1c8b5.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_intro_getting-started_md.7c901798.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_intro_welcome_md.69fe3324.js +1 -0
- package/doc_build/static/js/async/docs_en_guide_intro_why-module-engineering-solution_md.766afaee.js +1 -0
- package/doc_build/static/js/async/docs_en_index_md.32415ad9.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_guide_getting-started_mdx.c6631fd6.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_guide_plugin-object_mdx.0971cbdb.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_guide_setup-function_mdx.388d92b1.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_official-list_overview_md.9390ed67.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-babel_md.0528b729.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-banner_md.c14f8599.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-import_mdx.67bac7e1.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-node-polyfill_md.19819cf5.js +1 -0
- package/doc_build/static/js/async/docs_en_plugins_official-list_plugin-polyfill_md.473537df.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_config_build-config_md.e52b0287.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_config_build-preset_mdx.8b874378.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_config_design-system_md.ceae6914.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_config_dev_md.033094f8.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_config_plugins_md.ab43b516.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_config_testing_md.2c1f171d.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_index_md.5df1b9d0.js +1 -0
- package/doc_build/static/js/async/docs_zh_api_plugin-api_plugin-hooks_md.9f155180.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_advance_asset_mdx.0b551e5e.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_advance_build-umd_mdx.4c0a741d.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_advance_copy_md.ff70ddd3.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_advance_external-dependency_mdx.64bae82a.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_advance_in-depth-about-build_md.d16f07b4.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_advance_in-depth-about-dev-command_md.2eabb853.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_advance_theme-config_mdx.5670e00b.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_basic_before-getting-started_md.3e23f82e.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_basic_command-preview_md.718669ed.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_basic_modify-output-product_md.bea77add.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_basic_publish-your-project_md.b0c63699.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_basic_test-your-project_mdx.b9ee0af4.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_basic_use-micro-generator_md.ad32d392.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_basic_using-storybook_mdx.2748f6f6.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_best-practices_components_mdx.e4450a3c.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_faq_build_mdx.470ca09d.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_faq_index_md.9c5738a8.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_faq_storybook_mdx.e1fb8e18.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_faq_test_mdx.d332b61f.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_intro_getting-started_md.8af35ffc.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_intro_welcome_md.6169850d.js +1 -0
- package/doc_build/static/js/async/docs_zh_guide_intro_why-module-engineering-solution_md.ff0f5ef0.js +1 -0
- package/doc_build/static/js/async/docs_zh_index_md.bc7e2f02.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_guide_getting-started_mdx.6a2c07ee.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_guide_plugin-object_mdx.9a665baa.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_guide_setup-function_mdx.a614b224.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_official-list_overview_md.bf4a7405.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-babel_md.7107a66b.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-banner_md.4443ae99.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-import_mdx.e4923a9a.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-node-polyfill_md.26c9cb0d.js +1 -0
- package/doc_build/static/js/async/docs_zh_plugins_official-list_plugin-polyfill_md.0bda701d.js +1 -0
- 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 +1 -0
- 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 +20 -0
- package/doc_build/static/js/lib-lodash.20527186.js +1 -0
- package/doc_build/static/js/lib-polyfill.a99fdfae.js +1 -0
- package/doc_build/static/js/lib-react.87879e53.js +1 -0
- package/doc_build/static/js/lib-react.87879e53.js.LICENSE.txt +29 -0
- package/doc_build/static/js/lib-router.65b37e4a.js +1 -0
- package/doc_build/static/js/lib-router.65b37e4a.js.LICENSE.txt +32 -0
- package/doc_build/static/js/main.42725889.js +1 -0
- package/doc_build/static/search_index.en.6f4165d1.json +1 -0
- package/doc_build/static/search_index.en.8cd54797.json +1 -0
- package/doc_build/static/search_index.zh.7ed3054c.json +1 -0
- package/doc_build/static/search_index.zh.97edcc6e.json +1 -0
- package/docs/en/api/config/build-config.md +153 -38
- package/docs/en/api/config/build-preset.mdx +3 -3
- package/docs/en/api/config/design-system.md +3 -3
- package/docs/en/api/config/dev.md +22 -25
- package/docs/en/api/config/plugins.md +50 -5
- package/docs/en/api/config/testing.md +3 -3
- package/docs/en/components/faq-build-exception.mdx +1 -0
- package/docs/en/components/faq-build-other.mdx +0 -0
- package/docs/en/components/faq-build-product.mdx +0 -0
- package/docs/en/components/faq-storybook.mdx +0 -0
- package/docs/en/components/faq-test.mdx +1 -0
- package/docs/en/guide/advance/build-umd.mdx +1 -1
- package/docs/en/guide/basic/command-preview.md +2 -2
- package/docs/en/guide/basic/modify-output-product.md +16 -4
- package/docs/en/guide/best-practices/components.mdx +3 -3
- package/docs/en/guide/faq/_category_.json +4 -0
- package/docs/en/guide/faq/build.mdx +247 -0
- package/docs/en/guide/faq/index.md +7 -0
- package/docs/en/guide/faq/storybook.mdx +102 -0
- package/docs/en/guide/faq/test.mdx +11 -0
- package/docs/en/plugins/guide/setup-function.mdx +1 -1
- package/docs/en/plugins/official-list/plugin-banner.md +1 -1
- package/docs/en/plugins/official-list/plugin-import.mdx +34 -25
- package/docs/zh/api/config/build-config.md +158 -41
- package/docs/zh/api/config/build-preset.mdx +1 -1
- package/docs/zh/api/config/design-system.md +3 -3
- package/docs/zh/api/config/dev.md +23 -26
- package/docs/zh/api/config/plugins.md +50 -5
- package/docs/zh/api/config/testing.md +3 -3
- package/docs/zh/components/faq-build-exception.mdx +1 -0
- package/docs/zh/components/faq-build-other.mdx +0 -0
- package/docs/zh/components/faq-build-product.mdx +0 -0
- package/docs/zh/components/faq-storybook.mdx +0 -0
- package/docs/zh/components/faq-test.mdx +1 -0
- package/docs/zh/guide/advance/build-umd.mdx +1 -1
- package/docs/zh/guide/basic/before-getting-started.md +1 -1
- package/docs/zh/guide/basic/command-preview.md +3 -3
- package/docs/zh/guide/basic/modify-output-product.md +18 -7
- package/docs/zh/guide/best-practices/components.mdx +3 -3
- package/docs/zh/guide/faq/_category_.json +4 -0
- package/docs/zh/guide/faq/build.mdx +247 -0
- package/docs/zh/guide/faq/index.md +7 -0
- package/docs/zh/guide/faq/storybook.mdx +101 -0
- package/docs/zh/guide/faq/test.mdx +11 -0
- package/docs/zh/plugins/guide/setup-function.mdx +1 -1
- package/docs/zh/plugins/official-list/plugin-banner.md +1 -1
- package/docs/zh/plugins/official-list/plugin-import.mdx +30 -21
- package/modern.config.ts +7 -0
- package/package.json +3 -3
|
@@ -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 [
|
|
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 [
|
|
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 [
|
|
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).
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# Build FAQ
|
|
2
|
+
|
|
3
|
+
## Product FAQ
|
|
4
|
+
|
|
5
|
+
import BuildProductFAQ from '@site-docs-en/components/faq-build-product';
|
|
6
|
+
|
|
7
|
+
<BuildProductFAQ/>
|
|
8
|
+
|
|
9
|
+
### Initialization of Class Fields
|
|
10
|
+
|
|
11
|
+
TypeSript provides the `useDefineForClassFields` configuration to control the conversion handling for `public class fields`.
|
|
12
|
+
|
|
13
|
+
If we have a piece of code:
|
|
14
|
+
|
|
15
|
+
``` ts
|
|
16
|
+
class C {
|
|
17
|
+
foo = 100;
|
|
18
|
+
bar: string;
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
When `useDefineForClassFields` is `false`, then the compiled code will look like:
|
|
23
|
+
|
|
24
|
+
``` ts
|
|
25
|
+
class C {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.foo = 100;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
When `useDefineForClassFields` is `true`, then the compiled code will look like:
|
|
33
|
+
|
|
34
|
+
``` ts
|
|
35
|
+
class C {
|
|
36
|
+
constructor() {
|
|
37
|
+
Object.defineProperty(this, "foo", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: 100,
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "bar", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: void 0,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Also the default value of this configuration will change depending on the [`target`](https://www.typescriptlang.org/tsconfig#target) configuration of tsconfig.json: When `target` is ES2022 or higher, then `useDefineForClassFields` is configured to `true` by default, otherwise it defaults to `false`.
|
|
54
|
+
|
|
55
|
+
For more information on this configuration of TypeScript, you can refer to the following link:
|
|
56
|
+
|
|
57
|
+
- [The useDefineForClassFields Flag and The declare Property Modifier](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier)
|
|
58
|
+
|
|
59
|
+
The Modern.js Module will currently process according to the following logic:
|
|
60
|
+
|
|
61
|
+
1. The first decision to enable this feature inside Modern.js Module is based on the `useDefineForClassFields` configuration in tsconfig.json of the current project. Currently, only the contents of the tsconfig.json file under the current project path will be read, and the final tsconfig configuration based on the [`extends`](https://www.typescriptlang.org/tsconfig#extends) configuration is not supported at this time.
|
|
62
|
+
2. If the `useDefineForClassFields` configuration of tsconfig.json is not detected, the default value is determined based on the `target` configuration of tsconfig.json. If `target` is greater than `ES2022` (including `EsNext`), then `useDefineForClassFields` defaults to `true`, otherwise it is `false`.
|
|
63
|
+
3. If the `target` of tsconfig.json is not detected, it is processed according to the value of `useDefineForClassFields` as `true`.
|
|
64
|
+
|
|
65
|
+
### babel-plugin-lodash treats the introduced lodash as `undefined`
|
|
66
|
+
|
|
67
|
+
This problem occurs when using something like the following:
|
|
68
|
+
|
|
69
|
+
``` ts
|
|
70
|
+
import * as Lodash from 'lodash';
|
|
71
|
+
|
|
72
|
+
export const libs = {
|
|
73
|
+
_: Lodash,
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Current related issues on the `babel-plugin-lodash` Github:
|
|
78
|
+
|
|
79
|
+
- [#235](https://github.com/lodash/babel-plugin-lodash/issues/235)
|
|
80
|
+
|
|
81
|
+
The solution to this problem is to remove `babel-plugin-lodash`, since the plugin is not needed for on-demand referencing at this point and using it would have side effects.
|
|
82
|
+
|
|
83
|
+
A similar situation occurs with `babel-plugin-import`. If there is code like the following:
|
|
84
|
+
|
|
85
|
+
``` ts
|
|
86
|
+
import * as Comps from 'components';
|
|
87
|
+
|
|
88
|
+
export const libs = {
|
|
89
|
+
comps: Comps,
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
In this case `babel-plugin-import` may also cause `Comps` to become `undefined`. So you need to remove the corresponding `babel-plugin-import` as well.
|
|
94
|
+
|
|
95
|
+
## Exceptions FAQ
|
|
96
|
+
|
|
97
|
+
import BuildExceptionFAQ from '@site-docs-en/components/faq-build-exception';
|
|
98
|
+
|
|
99
|
+
<BuildExceptionFAQ />
|
|
100
|
+
|
|
101
|
+
### Dynamic require of "react" is not supported
|
|
102
|
+
|
|
103
|
+
#### Problem Description
|
|
104
|
+
|
|
105
|
+
When the product format in the product configuration of the build is ES modules.
|
|
106
|
+
|
|
107
|
+
``` ts
|
|
108
|
+
export default defineConfig({
|
|
109
|
+
buildConfig: {
|
|
110
|
+
format: 'esm',
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
If you import a cjs product from a third-party npm package, the resulting product may not work properly under webpack.
|
|
116
|
+
|
|
117
|
+

|
|
118
|
+
|
|
119
|
+
#### Solution
|
|
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://web-bnpm.byted.org/package/react-draggable), which only contains `cjs` products, then the problem is localized to the `react-draggable` package.
|
|
122
|
+
2. Then we need to exclude this package with the following configuration, i.e. **not package problematic third-party packages**.
|
|
123
|
+
|
|
124
|
+
``` ts
|
|
125
|
+
export default defineConfig({
|
|
126
|
+
buildConfig: {
|
|
127
|
+
externals: ['react-draggable'],
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### Reference Links
|
|
133
|
+
|
|
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
|
+
|
|
136
|
+
### During compilation, an error was reported in the less file of a component library:`'Operation on an invalid type'`
|
|
137
|
+
|
|
138
|
+
This is probably because the component library depends on Less version v3, while Modern.js Module defaults to v4. v3 and v4 have a Break Change in the `math` configuration, check this [link](https://stackoverflow.com/questions/73298187/less-error-operation-on-an-invalid-type-in-antd-dependency) for details.
|
|
139
|
+
|
|
140
|
+
Therefore, if a component library like this is used in the source code:
|
|
141
|
+
|
|
142
|
+
`buildPreset` is used in the build configuration, make the following changes:
|
|
143
|
+
|
|
144
|
+
``` js
|
|
145
|
+
module.exports = {
|
|
146
|
+
buildPreset({ extendPreset }) {
|
|
147
|
+
return extendPreset('your-build-preset', {
|
|
148
|
+
style: {
|
|
149
|
+
less: {
|
|
150
|
+
lessOptions: {
|
|
151
|
+
math: 'always',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Or, if a custom `buildConfig` is used, modify it as follows:
|
|
161
|
+
|
|
162
|
+
``` js
|
|
163
|
+
module.exports = {
|
|
164
|
+
buildConfig: {
|
|
165
|
+
style: {
|
|
166
|
+
less: {
|
|
167
|
+
lessOptions: {
|
|
168
|
+
math: 'always',
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
If you are using a component like this in Storybook, you will need to modify the debugging configuration of Storybook:
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
module.exports = {
|
|
180
|
+
dev: {
|
|
181
|
+
storybook: {
|
|
182
|
+
webpackChain(chain, { CHAIN_ID }) {
|
|
183
|
+
chain.module
|
|
184
|
+
.rule(CHAIN_ID.RULE.LESS)
|
|
185
|
+
.use(CHAIN_ID.USE.LESS)
|
|
186
|
+
.tap(options => {
|
|
187
|
+
options.lessOptions = {
|
|
188
|
+
...options.lessOptions,
|
|
189
|
+
math: 'always',
|
|
190
|
+
};
|
|
191
|
+
return options;
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Bundle DTS failed
|
|
200
|
+
|
|
201
|
+
Normally, the type file output with `tsc` is loose. Modern.js Module not only supports outputting loose type file products, but also supports packing type files, which allows you to package these loose type files and third-party dependent type files into one file.
|
|
202
|
+
|
|
203
|
+
However, there is a risk in packaging the type files of third-party dependencies, **because there are cases where the type files of third-party dependencies cannot be packaged**.
|
|
204
|
+
|
|
205
|
+
So when you encounter a `Bundle DTS failed` error message during the Modern.js Module build, you can observe that the error message comes from a third-party dependency. Try setting [`dts.respectExternal`](/api/config/build-config.html#dtsrespectexternal) to `false` to disable the behavior of packing type files of third-party dependencies.
|
|
206
|
+
|
|
207
|
+
### Error reported for `defineConfig` function type: `If there is no reference to "..." then the inferred type of "default" cannot be named`
|
|
208
|
+
|
|
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
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"include": ["src"]
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Other FAQ
|
|
218
|
+
|
|
219
|
+
import BuildOtherFAQ from '@site-docs-en/components/faq-build-other';
|
|
220
|
+
|
|
221
|
+
<BuildOtherFAQ />
|
|
222
|
+
|
|
223
|
+
### Add additional compilation feature
|
|
224
|
+
|
|
225
|
+
The Modern.js Module is based on the esbuild implementation, so if you have special needs or want to add additional compilation capabilities, you can do so by implementing the esbuild plugin.
|
|
226
|
+
|
|
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
|
+
|
|
229
|
+
``` js
|
|
230
|
+
export default defineConfig({
|
|
231
|
+
buildConfig: {
|
|
232
|
+
esbuildOptions: options => {
|
|
233
|
+
options.plugins = [
|
|
234
|
+
...options.plugins,
|
|
235
|
+
yourEsbuildPlugin,
|
|
236
|
+
];
|
|
237
|
+
return option;
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Support for generating TypeScript declaration files for CSS Modules
|
|
244
|
+
|
|
245
|
+
- First Solution: [typed-css-modules](https://github.com/Quramy/typed-css-modules)
|
|
246
|
+
- Second Solution: [postcss-modules-dts](https://www.npmjs.com/package/@guanghechen/postcss-modules-dts)
|
|
247
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Storybook FAQ
|
|
2
|
+
|
|
3
|
+
import BuildStorybookFAQ from '@site-docs-en/components/faq-storybook';
|
|
4
|
+
|
|
5
|
+
<BuildStorybookFAQ />
|
|
6
|
+
|
|
7
|
+
## Storybook v7 Support
|
|
8
|
+
|
|
9
|
+
Storybook v7 does not support it yet. Rspack builds are currently planned to be supported in Storybook v7, so progress will be slower.
|
|
10
|
+
|
|
11
|
+
Related Issue: [#3376](https://github.com/web-infra-dev/modern.js/issues/3376).
|
|
12
|
+
|
|
13
|
+
## Using Storybook Addon or other configurations does not work
|
|
14
|
+
|
|
15
|
+
Modern.js Module is currently using Storybook version v6, if you are using Addon version v7 you may not be able to get the addon to work.
|
|
16
|
+
|
|
17
|
+
In addition to the Addon, other configurations may also have differences. For example, if you modify the `preview.js` configuration file, Storybook v6 is written differently than v7:
|
|
18
|
+
|
|
19
|
+
- v6:[Document](https://storybook.js.org/docs/6.5/react/writing-stories/decorators#global-decorators)
|
|
20
|
+
- v7:[Document](https://storybook.js.org/docs/react/writing-stories/decorators#global-decorators)
|
|
21
|
+
|
|
22
|
+
## Cannot find module 'react-dom/package.json
|
|
23
|
+
|
|
24
|
+
When debug Storybook, the following problem occurs:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
ERR! Error: Cannot find module 'react-dom/package.json'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
You can install the react-dom dependency in the project.
|
|
31
|
+
|
|
32
|
+
``` json
|
|
33
|
+
{
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"react-dom": "^17"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Unable to locate the specific error message
|
|
41
|
+
|
|
42
|
+
Solutions:
|
|
43
|
+
|
|
44
|
+
1. Find `@storybook/core-server/dist/cjs/dev-server.js`
|
|
45
|
+
2. Find this code: `var _await$Promise$all = await Promise.all([preview, manager,`.
|
|
46
|
+
3. Modify it:
|
|
47
|
+
|
|
48
|
+
``` js
|
|
49
|
+
var _await$Promise$all = await Promise.all([
|
|
50
|
+
preview.catch(e => console.info(e)),
|
|
51
|
+
manager // TODO #13083 Restore this when compiling the preview is fast enough
|
|
52
|
+
// .then((result) => {
|
|
53
|
+
// if (!options.ci && !options.smokeTest) openInBrowser(address);
|
|
54
|
+
// return result;
|
|
55
|
+
// })
|
|
56
|
+
.catch(previewBuilder.bail)]),
|
|
57
|
+
_await$Promise$all2 = _slicedToArray(_await$Promise$all, 2),
|
|
58
|
+
previewResult = _await$Promise$all2[0],
|
|
59
|
+
managerResult = _await$Promise$all2[1]; // TODO #13083 Remove this when compiling the preview is fast enough
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Can`t find any stories is your Storybook
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+
|
|
66
|
+
When you get a problem like this, you can first open the browser console and there should be some error messages. You can use the error messages to deduce if there is a problem in the code you are writing that is causing Storybook to not work properly.
|
|
67
|
+
|
|
68
|
+
## Storybook Adds Proxy Functionality
|
|
69
|
+
|
|
70
|
+
Storybook does not provide a solution for this, but there is one in the Storybook Issue. In the Modern.js Module, you can:
|
|
71
|
+
|
|
72
|
+
1. Add the `config/storybook/middleware.js` file and initialize the following:
|
|
73
|
+
|
|
74
|
+
``` js
|
|
75
|
+
/* eslint-disable filenames/match-exported */
|
|
76
|
+
module.exports = function expressMiddleware(router) {
|
|
77
|
+
// router is express router
|
|
78
|
+
// import { Router } from 'express'
|
|
79
|
+
// router = new Router();
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2. add `http-proxy-middleware` dependency
|
|
84
|
+
3. Add proxy routing-related configuration
|
|
85
|
+
|
|
86
|
+
``` js
|
|
87
|
+
/* eslint-disable filenames/match-exported */
|
|
88
|
+
const { createProxyMiddleware } = require("http-proxy-middleware");
|
|
89
|
+
|
|
90
|
+
module.exports = function expressMiddleware (router) {
|
|
91
|
+
router.use('/api', createProxyMiddleware({
|
|
92
|
+
target: "http://localhost:8000",
|
|
93
|
+
changeOrigin: true
|
|
94
|
+
}))
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Link:https://github.com/storybookjs/storybook/issues/11551
|
|
99
|
+
|
|
100
|
+
## Modify the directory where the Story file exists
|
|
101
|
+
|
|
102
|
+
The directory where Story files are stored cannot be modified at the moment, only the `*.stories.(t|j)s(x)` and `*.stories.md(x)` files in the `your-project/stories` directory are recognized as Story files.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Test FAQ
|
|
2
|
+
|
|
3
|
+
import TestFAQ from '@site-docs-en/components/faq-test';
|
|
4
|
+
|
|
5
|
+
<TestFAQ />
|
|
6
|
+
|
|
7
|
+
### Execute `test` command with an error `TypeError: Cannot read property 'testEnvironmentOptions' of undefined`
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
You can check whether other projects in Monorepo have `jest-environment-jsdom` dependencies and unify them with the overrides provided by Monorepo.
|
|
@@ -4,7 +4,7 @@ sidebar_position: 3
|
|
|
4
4
|
|
|
5
5
|
# Setup function
|
|
6
6
|
|
|
7
|
-
In the [
|
|
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
|
|
|
@@ -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 [
|
|
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
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
121
|
-
|
|
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
|
-
|
|
140
|
-
|
|
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
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
pluginImport: [
|
|
176
|
+
{
|
|
177
|
+
libraryName: 'foo',
|
|
178
|
+
customName: 'foo/es/{{ kebabCase member }}',
|
|
179
|
+
},
|
|
180
|
+
],
|
|
172
181
|
}),
|
|
173
182
|
],
|
|
174
183
|
});
|