@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.98 → 3.8.1-ultramodern.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/modern-bundle-docs.js +7 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +5 -1
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +80 -11
- package/dist/cjs/bundleDocs.js +114 -0
- package/dist/cjs/commands/build.js +2 -1
- package/dist/cjs/commands/deploy.js +4 -2
- package/dist/cjs/commands/index.js +0 -4
- package/dist/cjs/config/default.js +2 -0
- package/dist/cjs/index.js +56 -15
- package/dist/cjs/plugins/analyze/index.js +2 -2
- package/dist/cjs/plugins/analyze/utils.js +3 -2
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +1 -1
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +94 -18
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/cjs/plugins/initialize/index.js +4 -3
- package/dist/cjs/plugins/serverBuild.js +3 -2
- package/dist/cjs/ultramodern-release-envelope/framework-output.js +109 -57
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +70 -10
- package/dist/esm/bundleDocs.mjs +62 -0
- package/dist/esm/commands/build.mjs +2 -1
- package/dist/esm/commands/deploy.mjs +4 -2
- package/dist/esm/commands/index.mjs +0 -4
- package/dist/esm/config/default.mjs +2 -0
- package/dist/esm/index.mjs +15 -1
- package/dist/esm/plugins/analyze/index.mjs +2 -2
- package/dist/esm/plugins/analyze/utils.mjs +3 -2
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -1
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +93 -18
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/esm/plugins/initialize/index.mjs +4 -3
- package/dist/esm/plugins/serverBuild.mjs +3 -2
- package/dist/esm/ultramodern-release-envelope/framework-output.mjs +107 -58
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +70 -10
- package/dist/esm-node/bundleDocs.mjs +63 -0
- package/dist/esm-node/commands/build.mjs +2 -1
- package/dist/esm-node/commands/deploy.mjs +4 -2
- package/dist/esm-node/commands/index.mjs +0 -4
- package/dist/esm-node/config/default.mjs +2 -0
- package/dist/esm-node/index.mjs +15 -1
- package/dist/esm-node/plugins/analyze/index.mjs +2 -2
- package/dist/esm-node/plugins/analyze/utils.mjs +3 -2
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -1
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +93 -18
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/esm-node/plugins/initialize/index.mjs +4 -3
- package/dist/esm-node/plugins/serverBuild.mjs +3 -2
- package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +107 -58
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +29 -0
- package/dist/types/bundleDocs.d.ts +20 -0
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/plugins/analyze/utils.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.d.mts +13 -0
- package/dist/types/types/config/dev.d.ts +6 -0
- package/dist/types/ultramodern-release-envelope/framework-output.d.ts +1 -0
- package/docs/apis/app/commands.md +231 -0
- package/docs/apis/app/hooks/api/lambda.md +9 -0
- package/docs/apis/app/hooks/config/favicon.md +24 -0
- package/docs/apis/app/hooks/config/html.md +5 -0
- package/docs/apis/app/hooks/config/icon.md +24 -0
- package/docs/apis/app/hooks/config/mock.md +6 -0
- package/docs/apis/app/hooks/config/public.md +26 -0
- package/docs/apis/app/hooks/config/upload.md +50 -0
- package/docs/apis/app/hooks/modern-config.md +5 -0
- package/docs/apis/app/hooks/server/server.md +5 -0
- package/docs/apis/app/hooks/shared.md +3 -0
- package/docs/apis/app/hooks/src/app.md +30 -0
- package/docs/apis/app/hooks/src/entry.md +34 -0
- package/docs/apis/app/hooks/src/entry.server.md +51 -0
- package/docs/apis/app/hooks/src/modern.runtime.md +5 -0
- package/docs/apis/app/hooks/src/routes.md +86 -0
- package/docs/apis/app/hooks/src/server.md +3 -0
- package/docs/apis/app/runtime/bff/use-backend-context.md +27 -0
- package/docs/apis/app/runtime/core/create-root.md +19 -0
- package/docs/apis/app/runtime/core/render.md +39 -0
- package/docs/apis/app/runtime/core/runtime-context.md +156 -0
- package/docs/apis/app/runtime/router/router.md +283 -0
- package/docs/apis/app/runtime/ssr/no-ssr.md +35 -0
- package/docs/apis/app/runtime/ssr/renderStreaming.md +67 -0
- package/docs/apis/app/runtime/ssr/renderString.md +60 -0
- package/docs/apis/app/runtime/ssr/requestHandler.md +44 -0
- package/docs/apis/app/runtime/utility/css-in-js.md +40 -0
- package/docs/apis/app/runtime/utility/head.md +35 -0
- package/docs/apis/app/runtime/utility/loadable.md +82 -0
- package/docs/community/blog/2022-0708-updates.md +91 -0
- package/docs/community/blog/2022-0910-updates.md +76 -0
- package/docs/community/blog/overview.md +63 -0
- package/docs/community/blog/v2-release-note.md +238 -0
- package/docs/community/blog/v3-release-note.md +622 -0
- package/docs/community/contributing-guide.md +252 -0
- package/docs/community/releases.md +23 -0
- package/docs/community/showcase.md +24 -0
- package/docs/community/team.md +14 -0
- package/docs/configure/app/bff/cross-project.md +20 -0
- package/docs/configure/app/bff/effect.md +313 -0
- package/docs/configure/app/bff/prefix.md +29 -0
- package/docs/configure/app/bff/runtime-framework.md +26 -0
- package/docs/configure/app/builder-plugins.md +66 -0
- package/docs/configure/app/dev/asset-prefix.md +13 -0
- package/docs/configure/app/dev/before-start-url.md +17 -0
- package/docs/configure/app/dev/client.md +41 -0
- package/docs/configure/app/dev/hmr.md +10 -0
- package/docs/configure/app/dev/host.md +18 -0
- package/docs/configure/app/dev/https.md +77 -0
- package/docs/configure/app/dev/lazy-compilation.md +39 -0
- package/docs/configure/app/dev/live-reload.md +10 -0
- package/docs/configure/app/dev/mock-dir.md +31 -0
- package/docs/configure/app/dev/progress-bar.md +19 -0
- package/docs/configure/app/dev/server.md +124 -0
- package/docs/configure/app/dev/setup-middlewares.md +32 -0
- package/docs/configure/app/dev/start-url.md +48 -0
- package/docs/configure/app/dev/watch-files.md +27 -0
- package/docs/configure/app/dev/write-to-disk.md +10 -0
- package/docs/configure/app/experiments/source-build.md +31 -0
- package/docs/configure/app/html/app-icon.md +28 -0
- package/docs/configure/app/html/crossorigin.md +10 -0
- package/docs/configure/app/html/favicon.md +16 -0
- package/docs/configure/app/html/inject.md +10 -0
- package/docs/configure/app/html/meta.md +24 -0
- package/docs/configure/app/html/mount-id.md +10 -0
- package/docs/configure/app/html/output-structure.md +10 -0
- package/docs/configure/app/html/script-loading.md +10 -0
- package/docs/configure/app/html/tags.md +15 -0
- package/docs/configure/app/html/template-parameters.md +33 -0
- package/docs/configure/app/html/template.md +10 -0
- package/docs/configure/app/html/title.md +18 -0
- package/docs/configure/app/output/asset-prefix.md +11 -0
- package/docs/configure/app/output/assets-retry.md +77 -0
- package/docs/configure/app/output/charset.md +10 -0
- package/docs/configure/app/output/clean-dist-path.md +16 -0
- package/docs/configure/app/output/convert-to-rem.md +79 -0
- package/docs/configure/app/output/copy.md +10 -0
- package/docs/configure/app/output/css-modules.md +48 -0
- package/docs/configure/app/output/data-uri-limit.md +26 -0
- package/docs/configure/app/output/disable-css-module-extension.md +55 -0
- package/docs/configure/app/output/disable-inline-runtime-chunk.md +41 -0
- package/docs/configure/app/output/disable-svgr.md +18 -0
- package/docs/configure/app/output/disable-ts-checker.md +49 -0
- package/docs/configure/app/output/dist-path.md +43 -0
- package/docs/configure/app/output/enable-asset-manifest.md +36 -0
- package/docs/configure/app/output/enable-css-module-tsdeclaration.md +28 -0
- package/docs/configure/app/output/enable-inline-route-manifests.md +16 -0
- package/docs/configure/app/output/externals.md +20 -0
- package/docs/configure/app/output/filename-hash.md +10 -0
- package/docs/configure/app/output/filename.md +55 -0
- package/docs/configure/app/output/inject-styles.md +10 -0
- package/docs/configure/app/output/inline-scripts.md +29 -0
- package/docs/configure/app/output/inline-styles.md +29 -0
- package/docs/configure/app/output/legal-comments.md +18 -0
- package/docs/configure/app/output/minify.md +22 -0
- package/docs/configure/app/output/override-browserslist.md +22 -0
- package/docs/configure/app/output/polyfill.md +12 -0
- package/docs/configure/app/output/source-map.md +30 -0
- package/docs/configure/app/output/split-route-chunks.md +16 -0
- package/docs/configure/app/output/ssg.md +81 -0
- package/docs/configure/app/output/ssgByEntries.md +90 -0
- package/docs/configure/app/output/svg-default-export.md +30 -0
- package/docs/configure/app/output/temp-dir.md +20 -0
- package/docs/configure/app/performance/build-cache.md +44 -0
- package/docs/configure/app/performance/chunk-split.md +40 -0
- package/docs/configure/app/performance/dns-prefetch.md +15 -0
- package/docs/configure/app/performance/preconnect.md +16 -0
- package/docs/configure/app/performance/prefetch.md +21 -0
- package/docs/configure/app/performance/preload.md +23 -0
- package/docs/configure/app/performance/print-file-size.md +40 -0
- package/docs/configure/app/performance/profile.md +10 -0
- package/docs/configure/app/performance/remove-console.md +10 -0
- package/docs/configure/app/performance/remove-moment-locale.md +10 -0
- package/docs/configure/app/performance/rsdoctor.md +38 -0
- package/docs/configure/app/plugins.md +59 -0
- package/docs/configure/app/resolve/alias-strategy.md +10 -0
- package/docs/configure/app/resolve/alias.md +9 -0
- package/docs/configure/app/resolve/condition-names.md +13 -0
- package/docs/configure/app/resolve/dedupe.md +9 -0
- package/docs/configure/app/resolve/extensions.md +13 -0
- package/docs/configure/app/runtime/0-intro.md +58 -0
- package/docs/configure/app/runtime/plugins.md +58 -0
- package/docs/configure/app/runtime/router.md +35 -0
- package/docs/configure/app/security/check-syntax.md +69 -0
- package/docs/configure/app/security/nonce.md +15 -0
- package/docs/configure/app/security/sri.md +20 -0
- package/docs/configure/app/server/base-url.md +26 -0
- package/docs/configure/app/server/port.md +18 -0
- package/docs/configure/app/server/public-routes.md +22 -0
- package/docs/configure/app/server/routes.md +86 -0
- package/docs/configure/app/server/rsc.md +22 -0
- package/docs/configure/app/server/ssr-by-entries.md +25 -0
- package/docs/configure/app/server/ssr.md +80 -0
- package/docs/configure/app/server/tsconfig-path.md +59 -0
- package/docs/configure/app/source/alias-strategy.md +14 -0
- package/docs/configure/app/source/alias.md +23 -0
- package/docs/configure/app/source/config-dir.md +20 -0
- package/docs/configure/app/source/decorators.md +25 -0
- package/docs/configure/app/source/define.md +16 -0
- package/docs/configure/app/source/disable-default-entries.md +28 -0
- package/docs/configure/app/source/enable-async-entry.md +54 -0
- package/docs/configure/app/source/enable-async-pre-entry.md +26 -0
- package/docs/configure/app/source/entries-dir.md +35 -0
- package/docs/configure/app/source/entries.md +179 -0
- package/docs/configure/app/source/exclude.md +10 -0
- package/docs/configure/app/source/global-vars.md +106 -0
- package/docs/configure/app/source/include.md +36 -0
- package/docs/configure/app/source/main-entry-name.md +24 -0
- package/docs/configure/app/source/pre-entry.md +10 -0
- package/docs/configure/app/source/react-compiler.md +68 -0
- package/docs/configure/app/source/transform-import.md +27 -0
- package/docs/configure/app/split-chunks.md +17 -0
- package/docs/configure/app/tools/autoprefixer.md +44 -0
- package/docs/configure/app/tools/bundler-chain.md +26 -0
- package/docs/configure/app/tools/css-extract.md +33 -0
- package/docs/configure/app/tools/css-loader.md +17 -0
- package/docs/configure/app/tools/dev-server.md +113 -0
- package/docs/configure/app/tools/html-plugin.md +41 -0
- package/docs/configure/app/tools/less.md +81 -0
- package/docs/configure/app/tools/lightningcss-loader.md +35 -0
- package/docs/configure/app/tools/minify-css.md +53 -0
- package/docs/configure/app/tools/postcss.md +34 -0
- package/docs/configure/app/tools/rspack.md +10 -0
- package/docs/configure/app/tools/sass.md +78 -0
- package/docs/configure/app/tools/style-loader.md +10 -0
- package/docs/configure/app/tools/swc.md +65 -0
- package/docs/configure/app/tools/ts-checker.md +116 -0
- package/docs/configure/app/usage.md +276 -0
- package/docs/guides/advanced-features/bff/cross-project.md +109 -0
- package/docs/guides/advanced-features/bff/data-platform.md +116 -0
- package/docs/guides/advanced-features/bff/extend-server.md +120 -0
- package/docs/guides/advanced-features/bff/frameworks.md +243 -0
- package/docs/guides/advanced-features/bff/function.md +318 -0
- package/docs/guides/advanced-features/bff/operators.md +554 -0
- package/docs/guides/advanced-features/bff/sdk.md +116 -0
- package/docs/guides/advanced-features/bff/upload.md +101 -0
- package/docs/guides/advanced-features/bff.md +18 -0
- package/docs/guides/advanced-features/build-performance.md +130 -0
- package/docs/guides/advanced-features/compatibility.md +120 -0
- package/docs/guides/advanced-features/international/advanced.md +128 -0
- package/docs/guides/advanced-features/international/api.md +267 -0
- package/docs/guides/advanced-features/international/best-practices.md +286 -0
- package/docs/guides/advanced-features/international/configuration.md +228 -0
- package/docs/guides/advanced-features/international/locale-detection.md +126 -0
- package/docs/guides/advanced-features/international/quick-start.md +128 -0
- package/docs/guides/advanced-features/international/resource-loading.md +154 -0
- package/docs/guides/advanced-features/international/routing.md +173 -0
- package/docs/guides/advanced-features/international.md +27 -0
- package/docs/guides/advanced-features/low-level.md +46 -0
- package/docs/guides/advanced-features/page-performance/code-split.md +77 -0
- package/docs/guides/advanced-features/page-performance/inline-assets.md +159 -0
- package/docs/guides/advanced-features/page-performance/optimize-bundle.md +97 -0
- package/docs/guides/advanced-features/page-performance/react-compiler.md +51 -0
- package/docs/guides/advanced-features/server-monitor/logger.md +41 -0
- package/docs/guides/advanced-features/server-monitor/metrics.md +58 -0
- package/docs/guides/advanced-features/server-monitor/monitors.md +242 -0
- package/docs/guides/advanced-features/source-build.md +164 -0
- package/docs/guides/advanced-features/web-server.md +288 -0
- package/docs/guides/basic-features/alias.md +102 -0
- package/docs/guides/basic-features/css/css-in-js.md +72 -0
- package/docs/guides/basic-features/css/css-modules.md +212 -0
- package/docs/guides/basic-features/css/css.md +27 -0
- package/docs/guides/basic-features/css/tailwindcss.md +27 -0
- package/docs/guides/basic-features/data/data-cache.md +510 -0
- package/docs/guides/basic-features/data/data-fetch.md +415 -0
- package/docs/guides/basic-features/data/data-write.md +227 -0
- package/docs/guides/basic-features/debug/mock.md +109 -0
- package/docs/guides/basic-features/debug/proxy.md +21 -0
- package/docs/guides/basic-features/debug/rsdoctor.md +47 -0
- package/docs/guides/basic-features/debug/using-storybook.md +112 -0
- package/docs/guides/basic-features/deploy.md +458 -0
- package/docs/guides/basic-features/env-vars.md +177 -0
- package/docs/guides/basic-features/html.md +255 -0
- package/docs/guides/basic-features/output-files.md +141 -0
- package/docs/guides/basic-features/render/before-render.md +108 -0
- package/docs/guides/basic-features/render/overview.md +47 -0
- package/docs/guides/basic-features/render/rsc.md +516 -0
- package/docs/guides/basic-features/render/ssg.md +228 -0
- package/docs/guides/basic-features/render/ssr-cache.md +201 -0
- package/docs/guides/basic-features/render/ssr.md +321 -0
- package/docs/guides/basic-features/render/streaming-ssr.md +264 -0
- package/docs/guides/basic-features/routes/config-routes.md +426 -0
- package/docs/guides/basic-features/routes/routes.md +524 -0
- package/docs/guides/basic-features/static-assets/json-files.md +120 -0
- package/docs/guides/basic-features/static-assets/svg-assets.md +168 -0
- package/docs/guides/basic-features/static-assets/wasm-assets.md +62 -0
- package/docs/guides/basic-features/static-assets.md +160 -0
- package/docs/guides/basic-features/testing/playwright.md +120 -0
- package/docs/guides/basic-features/testing/rstest.md +251 -0
- package/docs/guides/concept/builder.md +37 -0
- package/docs/guides/concept/entries.md +319 -0
- package/docs/guides/concept/server.md +35 -0
- package/docs/guides/get-started/ai-coding-agents.md +58 -0
- package/docs/guides/get-started/glossary.md +63 -0
- package/docs/guides/get-started/introduction.md +40 -0
- package/docs/guides/get-started/quick-start.md +269 -0
- package/docs/guides/get-started/tech-stack.md +91 -0
- package/docs/guides/get-started/ultramodern.md +440 -0
- package/docs/guides/get-started/upgrade.md +118 -0
- package/docs/guides/topic-detail/module-federation/application.md +116 -0
- package/docs/guides/topic-detail/module-federation/deploy.md +104 -0
- package/docs/guides/topic-detail/module-federation/i18n.md +670 -0
- package/docs/guides/topic-detail/module-federation/introduce.md +35 -0
- package/docs/guides/topic-detail/module-federation/ssr.md +182 -0
- package/docs/guides/topic-detail/module-federation/usage.md +219 -0
- package/docs/guides/troubleshooting/builder.md +110 -0
- package/docs/guides/troubleshooting/cli.md +35 -0
- package/docs/guides/troubleshooting/dependencies.md +119 -0
- package/docs/guides/troubleshooting/hmr.md +144 -0
- package/docs/guides/upgrade/config.md +954 -0
- package/docs/guides/upgrade/entry.md +463 -0
- package/docs/guides/upgrade/other.md +183 -0
- package/docs/guides/upgrade/overview.md +33 -0
- package/docs/guides/upgrade/tailwindcss.md +91 -0
- package/docs/guides/upgrade/web-server.md +109 -0
- package/docs/index.md +33 -0
- package/docs/llms.txt +290 -0
- package/docs/plugin/cli-plugins/api.md +573 -0
- package/docs/plugin/cli-plugins/life-cycle.md +2 -0
- package/docs/plugin/introduction.md +152 -0
- package/docs/plugin/official/cli-plugins/plugin-bff.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-ssg.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-styled-components.md +5 -0
- package/docs/plugin/official/cli-plugins.md +4 -0
- package/docs/plugin/plugin-system.md +238 -0
- package/docs/plugin/runtime-plugins/api.md +194 -0
- package/docs/plugin/runtime-plugins/life-cycle.md +2 -0
- package/docs/plugin/server-plugins/api.md +209 -0
- package/docs/plugin/server-plugins/life-cycle.md +13 -0
- package/docs/tutorials/examples/csr-auth.md +9 -0
- package/docs/tutorials/foundations/introduction.md +16 -0
- package/package.json +63 -22
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# tools.devServer
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object`
|
|
4
|
+
- **Default:** `{}`
|
|
5
|
+
|
|
6
|
+
The config of DevServer can be modified through `tools.devServer`.
|
|
7
|
+
|
|
8
|
+
### Options
|
|
9
|
+
|
|
10
|
+
#### compress
|
|
11
|
+
|
|
12
|
+
:::warning
|
|
13
|
+
**Deprecated**: This configuration is deprecated, please use [dev.server.compress](https://modernjs.dev/en/configure/app/dev/server) instead.
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
- **Type:** `boolean`
|
|
17
|
+
- **Default:** `true`
|
|
18
|
+
|
|
19
|
+
Whether to enable gzip compression for served static assets.
|
|
20
|
+
|
|
21
|
+
If you want to disable the gzip compression, you can set `compress` to `false`:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
export default {
|
|
25
|
+
tools: {
|
|
26
|
+
devServer: {
|
|
27
|
+
compress: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### headers
|
|
34
|
+
|
|
35
|
+
:::warning
|
|
36
|
+
**Deprecated**: This configuration is deprecated, please use [dev.server.headers](https://modernjs.dev/en/configure/app/dev/server) instead.
|
|
37
|
+
:::
|
|
38
|
+
|
|
39
|
+
- **Type:** `Record<string, string>`
|
|
40
|
+
- **Default:** `undefined`
|
|
41
|
+
|
|
42
|
+
Adds headers to all responses.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
export default {
|
|
46
|
+
tools: {
|
|
47
|
+
devServer: {
|
|
48
|
+
headers: {
|
|
49
|
+
'X-Custom-Foo': 'bar',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### historyApiFallback
|
|
57
|
+
|
|
58
|
+
:::warning
|
|
59
|
+
**Deprecated**: This configuration is deprecated, please use [dev.server.historyApiFallback](https://modernjs.dev/en/configure/app/dev/server) instead.
|
|
60
|
+
:::
|
|
61
|
+
|
|
62
|
+
- **Type:** `boolean | ConnectHistoryApiFallbackOptions`
|
|
63
|
+
- **Default:** `false`
|
|
64
|
+
|
|
65
|
+
The index.html page will likely have to be served in place of any 404 responses. Enable `devServer.historyApiFallback` by setting it to `true`:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
export default {
|
|
69
|
+
tools: {
|
|
70
|
+
devServer: {
|
|
71
|
+
historyApiFallback: true,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For more options and information, see the [connect-history-api-fallback](https://github.com/bripkens/connect-history-api-fallback) documentation.
|
|
78
|
+
|
|
79
|
+
#### proxy
|
|
80
|
+
|
|
81
|
+
:::warning
|
|
82
|
+
**Deprecated**: This configuration is deprecated, use [dev.server.proxy](https://modernjs.dev/en/configure/app/dev/server) instead.
|
|
83
|
+
:::
|
|
84
|
+
|
|
85
|
+
- **Type:** `ProxyOptions[] | Record<string, string | ProxyOptions>`
|
|
86
|
+
- **Default:** `undefined`
|
|
87
|
+
|
|
88
|
+
Configure proxy rules for the dev server, and forward requests to the specified service.
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
export default {
|
|
92
|
+
tools: {
|
|
93
|
+
devServer: {
|
|
94
|
+
proxy: {
|
|
95
|
+
// http://localhost:8080/api -> https://example.com/api
|
|
96
|
+
// http://localhost:8080/api/foo -> https://example.com/api/foo
|
|
97
|
+
'/api': 'https://example.com',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### watch
|
|
105
|
+
|
|
106
|
+
:::warning
|
|
107
|
+
**Deprecated**: This configuration is deprecated, please use [dev.server.watch](https://modernjs.dev/en/configure/app/dev/server) instead.
|
|
108
|
+
:::
|
|
109
|
+
|
|
110
|
+
- **Type:** `boolean`
|
|
111
|
+
- **Default:** `true`
|
|
112
|
+
|
|
113
|
+
Whether to watch files change in directories such as `mock/`, `server/`, `api/`.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# tools.htmlPlugin
|
|
2
|
+
|
|
3
|
+
- **Type:** `boolean | Object | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
meta, // 对应 `html.meta` 配置
|
|
9
|
+
title, // 对应 `html.title` 配置
|
|
10
|
+
inject, // 对应 `html.inject` 配置
|
|
11
|
+
favicon, // 对应 `html.favicon` 配置
|
|
12
|
+
template, // 对应 `html.template` 配置
|
|
13
|
+
filename, // 基于 `output.distPath` 和 `entryName` 生成
|
|
14
|
+
templateParameters, // 对应 `html.templateParameters` 配置
|
|
15
|
+
chunks: [entryName],
|
|
16
|
+
minify: {
|
|
17
|
+
// generated based on `output.minify`
|
|
18
|
+
removeComments: false,
|
|
19
|
+
useShortDoctype: true,
|
|
20
|
+
keepClosingSlash: true,
|
|
21
|
+
collapseWhitespace: true,
|
|
22
|
+
removeRedundantAttributes: true,
|
|
23
|
+
removeScriptTypeAttributes: true,
|
|
24
|
+
removeStyleLinkTypeAttributes: true,
|
|
25
|
+
removeEmptyAttributes: true,
|
|
26
|
+
minifyJS, // generated based on `output.charset`, `output.legalComments` and `performance.removeConsole`
|
|
27
|
+
minifyCSS: true,
|
|
28
|
+
minifyURLs: true,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
:::warning
|
|
34
|
+
SSR Application does not enable the `minify.removeComments` configuration, otherwise the SSR rendering will fail.
|
|
35
|
+
:::
|
|
36
|
+
|
|
37
|
+
The configs of [html-rspack-plugin](https://github.com/rstackjs/html-rspack-plugin) can be modified through `tools.htmlPlugin`.
|
|
38
|
+
|
|
39
|
+
:::info
|
|
40
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - tools.htmlPlugin](https://v2.rsbuild.dev/config/tools/html-plugin).
|
|
41
|
+
:::
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# tools.less
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
lessOptions: {
|
|
9
|
+
javascriptEnabled: true,
|
|
10
|
+
},
|
|
11
|
+
// CSS Source Map enabled by default in development environment
|
|
12
|
+
sourceMap: isDev,
|
|
13
|
+
};
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
You can modify the config of [less-loader](https://github.com/webpack-contrib/less-loader) via `tools.less`.
|
|
17
|
+
|
|
18
|
+
### Object Type
|
|
19
|
+
|
|
20
|
+
When `tools.less` is configured as `Object` type, it is merged with the default config through Object.assign in a shallow way. It should be noted that `lessOptions` is merged through deepMerge in a deep way. For example:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
export default {
|
|
24
|
+
tools: {
|
|
25
|
+
less: {
|
|
26
|
+
lessOptions: {
|
|
27
|
+
javascriptEnabled: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Function Type
|
|
35
|
+
|
|
36
|
+
When `tools.less` is a Function, the default config is passed as the first parameter, which can be directly modified or returned as the final result. The second parameter provides some utility functions that can be called directly. For example:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
export default {
|
|
40
|
+
tools: {
|
|
41
|
+
less(config) {
|
|
42
|
+
// Modify the config of lessOptions
|
|
43
|
+
config.lessOptions = {
|
|
44
|
+
javascriptEnabled: false,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Modifying Less Version
|
|
52
|
+
|
|
53
|
+
In some scenarios, if you need to use a specific version of Less instead of the built-in Less v4 in Modern.js, you can install the desired Less version in your project and set it up using the `implementation` option of the `less-loader`.
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
export default {
|
|
57
|
+
tools: {
|
|
58
|
+
less: {
|
|
59
|
+
implementation: require('less'),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Util Function
|
|
66
|
+
|
|
67
|
+
#### addExcludes
|
|
68
|
+
|
|
69
|
+
- **Type:** `(excludes: RegExp | RegExp[]) => void`
|
|
70
|
+
|
|
71
|
+
Used to specify which files `less-loader` does not compile, You can pass in one or more regular expressions to match the path of less files, for example:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
export default {
|
|
75
|
+
tools: {
|
|
76
|
+
less(config, { addExcludes }) {
|
|
77
|
+
addExcludes(/node_modules/);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# tools.lightningcssLoader
|
|
2
|
+
|
|
3
|
+
- **Type:** `Rspack.LightningcssLoaderOptions | Function | boolean`
|
|
4
|
+
- **Default:** `Rspack.LightningcssLoaderOptions | Function | boolean`
|
|
5
|
+
|
|
6
|
+
You can configure [builtin:lightningcss-loader](https://rspack.rs/guide/features/builtin-lightningcss-loader) through `tools.lightningcssLoader`.
|
|
7
|
+
|
|
8
|
+
## Enable loader
|
|
9
|
+
|
|
10
|
+
Set `tools.lightningcssLoader` to `true` to enable Rsbuild's built-in `lightningcss-loader`:
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
export default {
|
|
14
|
+
tools: {
|
|
15
|
+
lightningcssLoader: true,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
At this time, the default configuration is as follows:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
const defaultOptions = {
|
|
24
|
+
// use current browserslist config
|
|
25
|
+
targets: browserslist,
|
|
26
|
+
// minify is enabled when output.injectStyles is true and in production mode
|
|
27
|
+
minify: config.mode === 'production' && config.output.injectStyles,
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
It should be noted that when `lightningcss-loader` is turned on, `postcss-loader` will be turned off by default.
|
|
32
|
+
|
|
33
|
+
:::info
|
|
34
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - tools.lightningcssLoader](https://v2.rsbuild.dev/config/tools/lightningcss-loader).
|
|
35
|
+
:::
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# tools.minifyCss
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function | undefined`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
minimizerOptions: {
|
|
9
|
+
preset: [
|
|
10
|
+
'default',
|
|
11
|
+
{
|
|
12
|
+
mergeLonghand: false,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
When building for production, Modern.js will minimize the CSS code through [css-minimizer-webpack-plugin](https://github.com/webpack-contrib/css-minimizer-webpack-plugin). The config of [css-minimizer-webpack-plugin](https://github.com/webpack-contrib/css-minimizer-webpack-plugin) can be modified via `tools.minifyCss`.
|
|
20
|
+
|
|
21
|
+
### Object Type
|
|
22
|
+
|
|
23
|
+
When `tools.minifyCss` is `Object` type, it will be merged with the default config via `Object.assign`.
|
|
24
|
+
|
|
25
|
+
For example, modify the `preset` config of [cssnano](https://cssnano.co/):
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
export default {
|
|
29
|
+
tools: {
|
|
30
|
+
minifyCss: {
|
|
31
|
+
minimizerOptions: {
|
|
32
|
+
preset: require.resolve('cssnano-preset-simple'),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Function Type
|
|
40
|
+
|
|
41
|
+
When `tools.minifyCss` is `Function` type, the default config is passed in as the first parameter, the config object can be modified directly, or a value can be returned as the final result.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
export default {
|
|
45
|
+
tools: {
|
|
46
|
+
minifyCss: options => {
|
|
47
|
+
options.minimizerOptions = {
|
|
48
|
+
preset: require.resolve('cssnano-preset-simple'),
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
```
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# tools.postcss
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
postcssOptions: {
|
|
9
|
+
plugins: [
|
|
10
|
+
// The following plugins are enabled by default
|
|
11
|
+
require('postcss-nesting'),
|
|
12
|
+
require('postcss-media-minmax'),
|
|
13
|
+
require('postcss-flexbugs-fixes'),
|
|
14
|
+
require('autoprefixer')({
|
|
15
|
+
flexbox: 'no-2009',
|
|
16
|
+
}),
|
|
17
|
+
// The following plugins are only enabled when compatible with legacy browsers
|
|
18
|
+
require('postcss-custom-properties'),
|
|
19
|
+
require('postcss-initial'),
|
|
20
|
+
require('postcss-page-break'),
|
|
21
|
+
require('postcss-font-variant'),
|
|
22
|
+
],
|
|
23
|
+
sourceMap: isDev,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Modern.js integrates PostCSS by default, you can configure [postcss-loader](https://github.com/webpack-contrib/postcss-loader) through `tools.postcss`.
|
|
29
|
+
|
|
30
|
+
It should be noted that when you enable the `tools.lightningcss` configuration, PostCSS will be disabled by default, including `postcss-loader` and its default plugins.
|
|
31
|
+
|
|
32
|
+
:::info
|
|
33
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - tools.postcss](https://v2.rsbuild.dev/config/tools/postcss).
|
|
34
|
+
:::
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# tools.rspack
|
|
2
|
+
|
|
3
|
+
- **Type:** `Rspack.Configuration | Function | undefined`
|
|
4
|
+
- **Default:** `undefined`
|
|
5
|
+
|
|
6
|
+
`tools.rspack` is used to configure [Rspack](https://rspack.rs/).
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - tools.rspack](https://v2.rsbuild.dev/config/tools/rspack).
|
|
10
|
+
:::
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# tools.sass
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
// CSS Source Map enabled by default in development environment
|
|
9
|
+
sourceMap: isDev,
|
|
10
|
+
};
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
You can modify the config of [sass-loader](https://github.com/webpack-contrib/sass-loader) via `tools.sass`.
|
|
14
|
+
|
|
15
|
+
### Object Type
|
|
16
|
+
|
|
17
|
+
When `tools.sass` is `Object` type, it is merged with the default config through Object.assign. It should be noted that `sassOptions` is merged through deepMerge in a deep way.
|
|
18
|
+
|
|
19
|
+
For example:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
export default {
|
|
23
|
+
tools: {
|
|
24
|
+
sass: {
|
|
25
|
+
sourceMap: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Function Type
|
|
32
|
+
|
|
33
|
+
When `tools.sass` is a Function, the default config is passed as the first parameter, which can be directly modified or returned as the final result. The second parameter provides some utility functions that can be called directly. For Example:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
export default {
|
|
37
|
+
tools: {
|
|
38
|
+
sass(config) {
|
|
39
|
+
// Modify sourceMap config
|
|
40
|
+
config.additionalData = async (content, loaderContext) => {
|
|
41
|
+
// ...
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Modifying Sass Version
|
|
49
|
+
|
|
50
|
+
In some scenarios, if you need to use a specific version of Sass instead of the built-in Dart Sass v1 in Modern.js, you can install the desired Sass version in your project and set it up using the `implementation` option of the `sass-loader`.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
export default {
|
|
54
|
+
tools: {
|
|
55
|
+
sass: {
|
|
56
|
+
implementation: require('sass'),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Utility Function
|
|
63
|
+
|
|
64
|
+
#### addExcludes
|
|
65
|
+
|
|
66
|
+
- **Type:** `(excludes: RegExp | RegExp[]) => void`
|
|
67
|
+
|
|
68
|
+
Used to specify which files `sass-loader` does not compile, You can pass in one or more regular expressions to match the path of sass files, for example:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
export default {
|
|
72
|
+
tools: {
|
|
73
|
+
sass(config, { addExcludes }) {
|
|
74
|
+
addExcludes(/node_modules/);
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# tools.styleLoader
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:** `{}`
|
|
5
|
+
|
|
6
|
+
The config of [style-loader](https://github.com/webpack-contrib/style-loader) can be set through `tools.styleLoader`.
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - tools.styleLoader](https://v2.rsbuild.dev/config/tools/style-loader).
|
|
10
|
+
:::
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# tools.swc
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:** `undefined`
|
|
5
|
+
|
|
6
|
+
## Introduction
|
|
7
|
+
|
|
8
|
+
[SWC](https://SWC.rs/) (Speedy Web Compiler) is a transformer and minimizer for JavaScript and TypeScript based on `Rust`. SWC can provide the same abilities with Babel, and it's more than 10x faster than Babel.
|
|
9
|
+
|
|
10
|
+
Modern.js has a out-of-box plugin for SWC, power your Web application with Polyfill and minification, we also port some common used Babel plugins to SWC.
|
|
11
|
+
|
|
12
|
+
:::tip
|
|
13
|
+
When using Rspack as the bundler, SWC will be used for transpiling and compression by default, so you don't need to install or configure the SWC plugin.
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
## Used in Rspack mode
|
|
17
|
+
|
|
18
|
+
You can set the options of [builtin:swc-loader](https://rspack.rs/guide/features/builtin-swc-loader) through `tools.swc`.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
tools: {
|
|
25
|
+
swc: {
|
|
26
|
+
jsc: {
|
|
27
|
+
externalHelpers: false,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For more usage, please refer to [Rsbuild - tools.swc](https://v2.rsbuild.rs/config/tools/swc).
|
|
35
|
+
|
|
36
|
+
### Register SWC Plugin
|
|
37
|
+
|
|
38
|
+
Modern.js supports registering SWC's Wasm plugin through `tools.swc`, such as registering [@swc/plugin-styled-components](https://www.npmjs.com/package/@swc/plugin-styled-components):
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
export default {
|
|
42
|
+
tools: {
|
|
43
|
+
swc: {
|
|
44
|
+
jsc: {
|
|
45
|
+
experimental: {
|
|
46
|
+
plugins: [['@swc/plugin-styled-components', {}]],
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Please note that the SWC plugin is still an experimental feature, and the SWC Wasm plugin is currently not backward compatible. The version of the SWC plugin is closely tied to the version of swc\_core that Rspack depends on.
|
|
55
|
+
|
|
56
|
+
This means that you must to choose an SWC plugin that matches the current version of swc\_core to ensure that it works properly. If the version of the SWC plugin you are using does not match the version of swc\_core that Rspack depends on, Rspack will throw the following error during the build process:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
1: failed to run Wasm plugin transform. Please ensure the version of `swc_core`
|
|
60
|
+
used by the plugin is compatible with the host runtime.
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you encounter the above issues, a common solution is to upgrade both the Modern.js and SWC plugins to the latest versions.
|
|
64
|
+
|
|
65
|
+
For details, please refer to [Rsbuild - SWC Plugin Version](https://v2.rsbuild.rs/guide/configuration/swc#swc-plugin-version).
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# tools.tsChecker
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
typescript: {
|
|
9
|
+
// avoid OOM issue
|
|
10
|
+
memoryLimit: 8192,
|
|
11
|
+
// use tsconfig of user project
|
|
12
|
+
configFile: tsconfigPath,
|
|
13
|
+
// use TypeScript Go checker by default
|
|
14
|
+
tsgo: true,
|
|
15
|
+
// use TS-Go native preview of user project
|
|
16
|
+
typescriptPath: require.resolve('typescript/package.json'),
|
|
17
|
+
},
|
|
18
|
+
issue: {
|
|
19
|
+
exclude: [
|
|
20
|
+
{ file: '**/*.(spec|test).ts' },
|
|
21
|
+
{ file: '**/node_modules/**/*' },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
logger: {
|
|
25
|
+
log() {
|
|
26
|
+
// do nothing
|
|
27
|
+
// we only want to display error messages
|
|
28
|
+
},
|
|
29
|
+
error(message: string) {
|
|
30
|
+
console.error(message.replace(/ERROR/g, 'Type Error'));
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
By default, the [@rsbuild/plugin-type-check](https://github.com/rstackjs/rsbuild-plugin-type-check) is enabled for type checking. You can use `output.disableTsChecker` config to disable it.
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
### Object Type
|
|
41
|
+
|
|
42
|
+
When the value of `tsChecker` is an object, it will be deeply merged with the default configuration.
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
export default {
|
|
46
|
+
tools: {
|
|
47
|
+
tsChecker: {
|
|
48
|
+
issue: {
|
|
49
|
+
exclude: [({ file = '' }) => /[\\/]some-folder[\\/]/.test(file)],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Function Type
|
|
57
|
+
|
|
58
|
+
When the value of `tsChecker` is a function, the default configuration will be passed as the first argument. You can directly modify the configuration object or return an object as the final configuration.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
export default {
|
|
62
|
+
tools: {
|
|
63
|
+
tsChecker(options) {
|
|
64
|
+
options.async = false;
|
|
65
|
+
return options;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
> Please refer to [@rsbuild/plugin-type-check](https://github.com/rstackjs/rsbuild-plugin-type-check) for more details.
|
|
72
|
+
|
|
73
|
+
## TypeScript Go by Default
|
|
74
|
+
|
|
75
|
+
Type checking runs on [TypeScript Go](https://github.com/microsoft/typescript-go) (`tsgo`) by default in this fork. The capability is provided by [`ts-checker-rspack-plugin`](https://github.com/rstackjs/ts-checker-rspack-plugin), which is integrated by [`@rsbuild/plugin-type-check`](https://github.com/rstackjs/rsbuild-plugin-type-check), and reduces type-checking time by about 5-10x.
|
|
76
|
+
|
|
77
|
+
Modern.js prefers the project's stable `typescript` package when it is TypeScript 7 or newer, and falls back to `@typescript/native-preview` for projects still on the preview lane. To pin stable TypeScript 7, install it in your project:
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
```sh [npm]
|
|
81
|
+
npm install typescript -D
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```sh [yarn]
|
|
85
|
+
yarn add typescript -D
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```sh [pnpm]
|
|
89
|
+
pnpm add typescript -D
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
```sh [bun]
|
|
93
|
+
bun add typescript -D
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
```sh [deno]
|
|
97
|
+
deno add npm:typescript -D
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
When `tsgo` is enabled, the default `typescript.typescriptPath` resolves to `typescript/package.json` for TypeScript 7 projects. If you manually set `typescript.typescriptPath`, it must be an absolute path to `typescript/package.json` or `@typescript/native-preview/package.json`.
|
|
101
|
+
|
|
102
|
+
To fall back to the classic TypeScript checker, set `typescript.tsgo` to `false` and make sure `typescript` is installed in your project:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
export default {
|
|
106
|
+
tools: {
|
|
107
|
+
tsChecker: {
|
|
108
|
+
typescript: {
|
|
109
|
+
tsgo: false,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
For supported options and limitations, please refer to [ts-checker-rspack-plugin - TypeScript Go support](https://github.com/rstackjs/ts-checker-rspack-plugin#typescript-go-support).
|