@modern-js/app-tools 3.9.3 → 3.10.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.
Files changed (291) hide show
  1. package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +54 -2
  2. package/dist/cjs/compat/hooks.js +0 -5
  3. package/dist/cjs/compat/index.js +0 -5
  4. package/dist/cjs/compat/utils.js +0 -5
  5. package/dist/cjs/plugins/initialize/index.js +0 -1
  6. package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +54 -2
  7. package/dist/esm/compat/hooks.mjs +0 -5
  8. package/dist/esm/compat/index.mjs +0 -5
  9. package/dist/esm/compat/utils.mjs +0 -5
  10. package/dist/esm/plugins/initialize/index.mjs +0 -1
  11. package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +54 -2
  12. package/dist/esm-node/compat/hooks.mjs +0 -5
  13. package/dist/esm-node/compat/index.mjs +0 -5
  14. package/dist/esm-node/compat/utils.mjs +0 -5
  15. package/dist/esm-node/plugins/initialize/index.mjs +0 -1
  16. package/dist/types/types/config/index.d.ts +0 -2
  17. package/dist/types/types/config/tools.d.ts +0 -8
  18. package/docs/apis/app/commands.md +2 -0
  19. package/docs/apis/app/hooks/api/lambda.md +2 -0
  20. package/docs/apis/app/hooks/config/favicon.md +2 -0
  21. package/docs/apis/app/hooks/config/html.md +2 -0
  22. package/docs/apis/app/hooks/config/icon.md +2 -0
  23. package/docs/apis/app/hooks/config/mock.md +2 -0
  24. package/docs/apis/app/hooks/config/public.md +2 -0
  25. package/docs/apis/app/hooks/config/upload.md +3 -3
  26. package/docs/apis/app/hooks/modern-config.md +2 -0
  27. package/docs/apis/app/hooks/server/server.md +2 -0
  28. package/docs/apis/app/hooks/shared.md +2 -0
  29. package/docs/apis/app/hooks/src/app.md +2 -0
  30. package/docs/apis/app/hooks/src/entry.md +2 -0
  31. package/docs/apis/app/hooks/src/entry.server.md +2 -0
  32. package/docs/apis/app/hooks/src/modern.runtime.md +2 -0
  33. package/docs/apis/app/hooks/src/routes.md +2 -0
  34. package/docs/apis/app/hooks/src/server.md +2 -0
  35. package/docs/apis/app/runtime/bff/use-hono-context.md +2 -0
  36. package/docs/apis/app/runtime/core/create-root.md +5 -1
  37. package/docs/apis/app/runtime/core/render.md +7 -2
  38. package/docs/apis/app/runtime/core/runtime-context.md +18 -16
  39. package/docs/apis/app/runtime/router/router.md +11 -6
  40. package/docs/apis/app/runtime/ssr/no-ssr.md +2 -0
  41. package/docs/apis/app/runtime/ssr/renderStreaming.md +2 -0
  42. package/docs/apis/app/runtime/ssr/renderString.md +2 -0
  43. package/docs/apis/app/runtime/ssr/requestHandler.md +2 -0
  44. package/docs/apis/app/runtime/utility/css-in-js.md +2 -0
  45. package/docs/apis/app/runtime/utility/head.md +2 -0
  46. package/docs/apis/app/runtime/utility/loadable.md +2 -0
  47. package/docs/community/blog/2022-0708-updates.md +2 -0
  48. package/docs/community/blog/2022-0910-updates.md +2 -0
  49. package/docs/community/blog/overview.md +2 -0
  50. package/docs/community/blog/v2-release-note.md +2 -0
  51. package/docs/community/blog/v3-release-note.md +18 -13
  52. package/docs/community/contributing-guide.md +17 -33
  53. package/docs/community/releases.md +2 -0
  54. package/docs/community/showcase.md +2 -0
  55. package/docs/community/team.md +2 -0
  56. package/docs/configure/app/bff/cross-project.md +2 -0
  57. package/docs/configure/app/bff/prefix.md +2 -0
  58. package/docs/configure/app/builder-plugins.md +2 -0
  59. package/docs/configure/app/dev/asset-prefix.md +2 -0
  60. package/docs/configure/app/dev/before-start-url.md +2 -0
  61. package/docs/configure/app/dev/client.md +2 -0
  62. package/docs/configure/app/dev/hmr.md +2 -0
  63. package/docs/configure/app/dev/host.md +2 -0
  64. package/docs/configure/app/dev/https.md +2 -0
  65. package/docs/configure/app/dev/lazy-compilation.md +19 -1
  66. package/docs/configure/app/dev/live-reload.md +2 -0
  67. package/docs/configure/app/dev/mock-dir.md +2 -0
  68. package/docs/configure/app/dev/progress-bar.md +2 -0
  69. package/docs/configure/app/dev/server.md +2 -0
  70. package/docs/configure/app/dev/setup-middlewares.md +2 -0
  71. package/docs/configure/app/dev/start-url.md +2 -0
  72. package/docs/configure/app/dev/watch-files.md +2 -0
  73. package/docs/configure/app/dev/write-to-disk.md +2 -0
  74. package/docs/configure/app/experiments/source-build.md +2 -0
  75. package/docs/configure/app/html/app-icon.md +2 -0
  76. package/docs/configure/app/html/crossorigin.md +2 -0
  77. package/docs/configure/app/html/favicon.md +2 -0
  78. package/docs/configure/app/html/inject.md +2 -0
  79. package/docs/configure/app/html/meta.md +2 -0
  80. package/docs/configure/app/html/mount-id.md +2 -0
  81. package/docs/configure/app/html/output-structure.md +2 -0
  82. package/docs/configure/app/html/script-loading.md +2 -0
  83. package/docs/configure/app/html/tags.md +2 -0
  84. package/docs/configure/app/html/template-parameters.md +2 -0
  85. package/docs/configure/app/html/template.md +2 -0
  86. package/docs/configure/app/html/title.md +2 -0
  87. package/docs/configure/app/output/asset-prefix.md +2 -0
  88. package/docs/configure/app/output/assets-retry.md +2 -0
  89. package/docs/configure/app/output/charset.md +2 -0
  90. package/docs/configure/app/output/clean-dist-path.md +2 -0
  91. package/docs/configure/app/output/convert-to-rem.md +2 -0
  92. package/docs/configure/app/output/copy.md +2 -0
  93. package/docs/configure/app/output/css-modules.md +3 -5
  94. package/docs/configure/app/output/data-uri-limit.md +2 -0
  95. package/docs/configure/app/output/disable-css-module-extension.md +2 -0
  96. package/docs/configure/app/output/disable-inline-runtime-chunk.md +2 -0
  97. package/docs/configure/app/output/disable-svgr.md +2 -0
  98. package/docs/configure/app/output/disable-ts-checker.md +2 -0
  99. package/docs/configure/app/output/dist-path.md +2 -0
  100. package/docs/configure/app/output/enable-asset-manifest.md +2 -0
  101. package/docs/configure/app/output/enable-css-module-tsdeclaration.md +2 -0
  102. package/docs/configure/app/output/enable-inline-route-manifests.md +2 -0
  103. package/docs/configure/app/output/externals.md +2 -0
  104. package/docs/configure/app/output/filename-hash.md +2 -0
  105. package/docs/configure/app/output/filename.md +2 -0
  106. package/docs/configure/app/output/inject-styles.md +2 -0
  107. package/docs/configure/app/output/inline-scripts.md +3 -2
  108. package/docs/configure/app/output/inline-styles.md +3 -2
  109. package/docs/configure/app/output/legal-comments.md +2 -0
  110. package/docs/configure/app/output/minify.md +2 -0
  111. package/docs/configure/app/output/override-browserslist.md +2 -0
  112. package/docs/configure/app/output/polyfill.md +2 -0
  113. package/docs/configure/app/output/source-map.md +2 -0
  114. package/docs/configure/app/output/split-route-chunks.md +3 -1
  115. package/docs/configure/app/output/ssg.md +2 -0
  116. package/docs/configure/app/output/ssgByEntries.md +2 -0
  117. package/docs/configure/app/output/svg-default-export.md +2 -0
  118. package/docs/configure/app/output/temp-dir.md +2 -0
  119. package/docs/configure/app/performance/build-cache.md +2 -0
  120. package/docs/configure/app/performance/chunk-split.md +3 -4
  121. package/docs/configure/app/performance/dns-prefetch.md +2 -0
  122. package/docs/configure/app/performance/preconnect.md +2 -0
  123. package/docs/configure/app/performance/prefetch.md +2 -0
  124. package/docs/configure/app/performance/preload.md +2 -0
  125. package/docs/configure/app/performance/print-file-size.md +2 -0
  126. package/docs/configure/app/performance/profile.md +2 -0
  127. package/docs/configure/app/performance/remove-console.md +2 -0
  128. package/docs/configure/app/performance/remove-moment-locale.md +2 -0
  129. package/docs/configure/app/plugins.md +2 -0
  130. package/docs/configure/app/resolve/alias-strategy.md +2 -0
  131. package/docs/configure/app/resolve/alias.md +2 -0
  132. package/docs/configure/app/resolve/condition-names.md +2 -0
  133. package/docs/configure/app/resolve/dedupe.md +2 -0
  134. package/docs/configure/app/resolve/extensions.md +2 -0
  135. package/docs/configure/app/runtime/0-intro.md +2 -0
  136. package/docs/configure/app/runtime/plugins.md +8 -4
  137. package/docs/configure/app/runtime/router.md +2 -0
  138. package/docs/configure/app/security/check-syntax.md +2 -0
  139. package/docs/configure/app/security/nonce.md +2 -0
  140. package/docs/configure/app/security/sri.md +2 -0
  141. package/docs/configure/app/server/base-url.md +2 -0
  142. package/docs/configure/app/server/port.md +2 -0
  143. package/docs/configure/app/server/public-routes.md +2 -0
  144. package/docs/configure/app/server/routes.md +2 -0
  145. package/docs/configure/app/server/rsc.md +2 -0
  146. package/docs/configure/app/server/ssr-by-entries.md +2 -0
  147. package/docs/configure/app/server/ssr.md +3 -1
  148. package/docs/configure/app/server/tsconfig-path.md +4 -2
  149. package/docs/configure/app/source/alias-strategy.md +2 -0
  150. package/docs/configure/app/source/alias.md +2 -0
  151. package/docs/configure/app/source/config-dir.md +2 -0
  152. package/docs/configure/app/source/decorators.md +2 -0
  153. package/docs/configure/app/source/define.md +2 -0
  154. package/docs/configure/app/source/disable-default-entries.md +2 -0
  155. package/docs/configure/app/source/enable-async-entry.md +2 -0
  156. package/docs/configure/app/source/enable-async-pre-entry.md +2 -0
  157. package/docs/configure/app/source/entries-dir.md +2 -0
  158. package/docs/configure/app/source/entries.md +2 -0
  159. package/docs/configure/app/source/exclude.md +2 -0
  160. package/docs/configure/app/source/global-vars.md +2 -0
  161. package/docs/configure/app/source/include.md +2 -0
  162. package/docs/configure/app/source/main-entry-name.md +2 -0
  163. package/docs/configure/app/source/pre-entry.md +2 -0
  164. package/docs/configure/app/source/react-compiler.md +2 -0
  165. package/docs/configure/app/source/transform-import.md +2 -0
  166. package/docs/configure/app/split-chunks.md +2 -0
  167. package/docs/configure/app/tools/autoprefixer.md +2 -0
  168. package/docs/configure/app/tools/bundler-chain.md +2 -0
  169. package/docs/configure/app/tools/css-extract.md +2 -0
  170. package/docs/configure/app/tools/css-loader.md +2 -0
  171. package/docs/configure/app/tools/dev-server.md +2 -0
  172. package/docs/configure/app/tools/html-plugin.md +2 -0
  173. package/docs/configure/app/tools/less.md +2 -0
  174. package/docs/configure/app/tools/lightningcss-loader.md +2 -0
  175. package/docs/configure/app/tools/minify-css.md +2 -0
  176. package/docs/configure/app/tools/postcss.md +2 -0
  177. package/docs/configure/app/tools/rspack.md +2 -0
  178. package/docs/configure/app/tools/sass.md +8 -6
  179. package/docs/configure/app/tools/style-loader.md +2 -0
  180. package/docs/configure/app/tools/svgr.md +2 -0
  181. package/docs/configure/app/tools/swc.md +2 -0
  182. package/docs/configure/app/tools/ts-checker.md +2 -0
  183. package/docs/configure/app/usage.md +3 -5
  184. package/docs/guides/advanced-features/bff/cross-project.md +6 -4
  185. package/docs/guides/advanced-features/bff/extend-server.md +2 -0
  186. package/docs/guides/advanced-features/bff/frameworks.md +2 -0
  187. package/docs/guides/advanced-features/bff/function.md +2 -0
  188. package/docs/guides/advanced-features/bff/operators.md +2 -0
  189. package/docs/guides/advanced-features/bff/sdk.md +2 -0
  190. package/docs/guides/advanced-features/bff/upload.md +2 -0
  191. package/docs/guides/advanced-features/bff.md +2 -0
  192. package/docs/guides/advanced-features/build-performance.md +2 -0
  193. package/docs/guides/advanced-features/compatibility.md +2 -0
  194. package/docs/guides/advanced-features/international/advanced.md +3 -1
  195. package/docs/guides/advanced-features/international/api.md +21 -13
  196. package/docs/guides/advanced-features/international/best-practices.md +17 -15
  197. package/docs/guides/advanced-features/international/configuration.md +3 -1
  198. package/docs/guides/advanced-features/international/locale-detection.md +15 -4
  199. package/docs/guides/advanced-features/international/quick-start.md +2 -0
  200. package/docs/guides/advanced-features/international/resource-loading.md +11 -7
  201. package/docs/guides/advanced-features/international/routing.md +5 -1
  202. package/docs/guides/advanced-features/international.md +2 -0
  203. package/docs/guides/advanced-features/low-level.md +2 -0
  204. package/docs/guides/advanced-features/page-performance/code-split.md +2 -0
  205. package/docs/guides/advanced-features/page-performance/inline-assets.md +2 -0
  206. package/docs/guides/advanced-features/page-performance/optimize-bundle.md +2 -0
  207. package/docs/guides/advanced-features/page-performance/react-compiler.md +2 -0
  208. package/docs/guides/advanced-features/server-monitor/logger.md +2 -0
  209. package/docs/guides/advanced-features/server-monitor/metrics.md +2 -0
  210. package/docs/guides/advanced-features/server-monitor/monitors.md +3 -3
  211. package/docs/guides/advanced-features/source-build.md +3 -1
  212. package/docs/guides/advanced-features/web-server.md +5 -3
  213. package/docs/guides/basic-features/alias.md +2 -0
  214. package/docs/guides/basic-features/css/css-in-js.md +2 -0
  215. package/docs/guides/basic-features/css/css-modules.md +2 -0
  216. package/docs/guides/basic-features/css/css.md +2 -0
  217. package/docs/guides/basic-features/css/tailwindcss.md +2 -0
  218. package/docs/guides/basic-features/data/data-cache.md +2 -0
  219. package/docs/guides/basic-features/data/data-fetch.md +3 -3
  220. package/docs/guides/basic-features/data/data-write.md +25 -28
  221. package/docs/guides/basic-features/debug/mock.md +4 -2
  222. package/docs/guides/basic-features/debug/proxy.md +2 -0
  223. package/docs/guides/basic-features/debug/rsdoctor.md +2 -0
  224. package/docs/guides/basic-features/debug/using-storybook.md +6 -4
  225. package/docs/guides/basic-features/deploy.md +2 -0
  226. package/docs/guides/basic-features/env-vars.md +2 -0
  227. package/docs/guides/basic-features/html.md +4 -3
  228. package/docs/guides/basic-features/output-files.md +3 -1
  229. package/docs/guides/basic-features/render/before-render.md +2 -0
  230. package/docs/guides/basic-features/render/overview.md +2 -0
  231. package/docs/guides/basic-features/render/rsc.md +12 -2
  232. package/docs/guides/basic-features/render/ssg.md +2 -0
  233. package/docs/guides/basic-features/render/ssr-cache.md +2 -0
  234. package/docs/guides/basic-features/render/ssr.md +10 -12
  235. package/docs/guides/basic-features/render/streaming-ssr.md +4 -1
  236. package/docs/guides/basic-features/routes/config-routes.md +54 -54
  237. package/docs/guides/basic-features/routes/routes.md +2 -0
  238. package/docs/guides/basic-features/static-assets/json-files.md +2 -0
  239. package/docs/guides/basic-features/static-assets/svg-assets.md +2 -0
  240. package/docs/guides/basic-features/static-assets/wasm-assets.md +2 -0
  241. package/docs/guides/basic-features/static-assets.md +2 -0
  242. package/docs/guides/basic-features/testing/playwright.md +8 -6
  243. package/docs/guides/basic-features/testing/rstest.md +7 -5
  244. package/docs/guides/concept/builder.md +2 -0
  245. package/docs/guides/concept/entries.md +2 -0
  246. package/docs/guides/concept/server.md +2 -0
  247. package/docs/guides/get-started/ai-coding-agents.md +5 -3
  248. package/docs/guides/get-started/glossary.md +2 -0
  249. package/docs/guides/get-started/introduction.md +2 -0
  250. package/docs/guides/get-started/quick-start.md +13 -5
  251. package/docs/guides/get-started/tech-stack.md +2 -0
  252. package/docs/guides/get-started/upgrade.md +2 -0
  253. package/docs/guides/topic-detail/module-federation/application.md +2 -0
  254. package/docs/guides/topic-detail/module-federation/deploy.md +4 -2
  255. package/docs/guides/topic-detail/module-federation/i18n.md +2 -0
  256. package/docs/guides/topic-detail/module-federation/introduce.md +2 -0
  257. package/docs/guides/topic-detail/module-federation/ssr.md +2 -0
  258. package/docs/guides/topic-detail/module-federation/usage.md +2 -0
  259. package/docs/guides/troubleshooting/builder.md +2 -0
  260. package/docs/guides/troubleshooting/cli.md +2 -0
  261. package/docs/guides/troubleshooting/dependencies.md +2 -0
  262. package/docs/guides/troubleshooting/hmr.md +2 -0
  263. package/docs/guides/upgrade/config.md +14 -0
  264. package/docs/guides/upgrade/entry.md +2 -0
  265. package/docs/guides/upgrade/other.md +2 -0
  266. package/docs/guides/upgrade/overview.md +2 -0
  267. package/docs/guides/upgrade/tailwindcss.md +2 -0
  268. package/docs/guides/upgrade/web-server.md +25 -6
  269. package/docs/index.md +2 -0
  270. package/docs/llms.txt +5 -5
  271. package/docs/plugin/cli-plugins/api.md +2 -0
  272. package/docs/plugin/cli-plugins/life-cycle.md +2 -0
  273. package/docs/plugin/introduction.md +2 -0
  274. package/docs/plugin/official/cli-plugins/plugin-bff.md +2 -0
  275. package/docs/plugin/official/cli-plugins/plugin-ssg.md +2 -0
  276. package/docs/plugin/official/cli-plugins/plugin-styled-components.md +2 -0
  277. package/docs/plugin/official/cli-plugins.md +2 -0
  278. package/docs/plugin/plugin-system.md +3 -3
  279. package/docs/plugin/runtime-plugins/api.md +2 -0
  280. package/docs/plugin/runtime-plugins/life-cycle.md +2 -0
  281. package/docs/plugin/server-plugins/api.md +2 -0
  282. package/docs/plugin/server-plugins/life-cycle.md +2 -0
  283. package/docs/tutorials/examples/csr-auth.md +2 -0
  284. package/docs/tutorials/foundations/introduction.md +2 -0
  285. package/lib/types.d.ts +0 -1
  286. package/package.json +16 -17
  287. package/{rslib.config.mts → rstack.config.mts} +4 -4
  288. package/dist/cjs/types/config/testing.js +0 -18
  289. package/dist/esm/types/config/testing.mjs +0 -0
  290. package/dist/esm-node/types/config/testing.mjs +0 -1
  291. package/dist/types/types/config/testing.d.ts +0 -8
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Config Routes
2
4
 
3
5
  By default, Modern.js recommends using [Convention Routes](/guides/basic-features/routes/routes.md) as the way to define routes. At the same time, Modern.js also provides a config-based routing capability that can be used together with convention routes or used separately.
@@ -17,13 +19,11 @@ Config routes are particularly useful in the following scenarios:
17
19
  In the `src` directory or each entry directory, you can define a `modern.routes.ts` file to configure routes:
18
20
 
19
21
  ```ts
20
- import { defineRoutes } from '@modern-js/runtime/config-routes'
22
+ import { defineRoutes } from '@modern-js/runtime/config-routes';
21
23
 
22
24
  export default defineRoutes(({ route, layout, page, $ }, fileRoutes) => {
23
- return [
24
- route("home.tsx", "/"),
25
- ]
26
- })
25
+ return [route('home.tsx', '/')];
26
+ });
27
27
  ```
28
28
 
29
29
  ### Function Signature Description
@@ -69,24 +69,24 @@ The `route` function is a general-purpose route configuration function that auto
69
69
  export default defineRoutes(({ route }, fileRoutes) => {
70
70
  return [
71
71
  // When no child routes, automatically generates page route
72
- route("home.tsx", "/"),
73
- route("about.tsx", "about"),
72
+ route('home.tsx', '/'),
73
+ route('about.tsx', 'about'),
74
74
 
75
75
  // When has child routes, automatically generates layout route
76
76
  // dashboard/layout.tsx needs to contain <Outlet> to render child routes
77
- route("dashboard/layout.tsx", "dashboard", [
78
- route("dashboard/overview.tsx", "overview"), // Generated path: /dashboard/overview
79
- route("dashboard/settings.tsx", "settings"), // Generated path: /dashboard/settings
77
+ route('dashboard/layout.tsx', 'dashboard', [
78
+ route('dashboard/overview.tsx', 'overview'), // Generated path: /dashboard/overview
79
+ route('dashboard/settings.tsx', 'settings'), // Generated path: /dashboard/settings
80
80
  ]),
81
81
 
82
82
  // Dynamic routes
83
- route("products/detail.tsx", "products/:id"),
83
+ route('products/detail.tsx', 'products/:id'),
84
84
 
85
85
  // Multiple paths pointing to the same component
86
- route("user/profile.tsx", "user"),
87
- route("user/profile.tsx", "profile"),
88
- ]
89
- })
86
+ route('user/profile.tsx', 'user'),
87
+ route('user/profile.tsx', 'profile'),
88
+ ];
89
+ });
90
90
  ```
91
91
 
92
92
  **Use cases**:
@@ -102,12 +102,12 @@ The `layout` function is specifically used to configure layout routes, always ge
102
102
  export default defineRoutes(({ layout, page }, fileRoutes) => {
103
103
  return [
104
104
  // Generate layout route with path "/auth", must contain child routes
105
- layout("auth/layout.tsx", "auth", [
106
- page("auth/login/page.tsx", "login"), // Generated path: /auth/login
107
- page("auth/register/page.tsx", "register"), // Generated path: /auth/register
105
+ layout('auth/layout.tsx', 'auth', [
106
+ page('auth/login/page.tsx', 'login'), // Generated path: /auth/login
107
+ page('auth/register/page.tsx', 'register'), // Generated path: /auth/register
108
108
  ]),
109
- ]
110
- })
109
+ ];
110
+ });
111
111
  ```
112
112
 
113
113
  **Use cases**:
@@ -123,12 +123,12 @@ The `page` function is specifically used to configure page routes, always genera
123
123
  ```ts
124
124
  export default defineRoutes(({ layout, page }, fileRoutes) => {
125
125
  return [
126
- layout("dashboard/layout.tsx", "dashboard", [
127
- page("dashboard/overview.tsx", "overview"), // Generated path: /dashboard/overview
128
- page("dashboard/settings.tsx", "settings"), // Generated path: /dashboard/settings
126
+ layout('dashboard/layout.tsx', 'dashboard', [
127
+ page('dashboard/overview.tsx', 'overview'), // Generated path: /dashboard/overview
128
+ page('dashboard/settings.tsx', 'settings'), // Generated path: /dashboard/settings
129
129
  ]),
130
- ]
131
- })
130
+ ];
131
+ });
132
132
  ```
133
133
 
134
134
  **Use cases**:
@@ -144,13 +144,13 @@ The `$` function is specifically used to configure wildcard routes for handling
144
144
  ```ts
145
145
  export default defineRoutes(({ layout, page, $ }, fileRoutes) => {
146
146
  return [
147
- layout("blog/layout.tsx", "blog", [
148
- page("blog/page.tsx", ""), // Generated path: /blog
149
- page("blog/[id]/page.tsx", ":id"), // Generated path: /blog/:id
150
- $("blog/$.tsx", "*"), // Wildcard route, matches all unmatched paths under /blog
147
+ layout('blog/layout.tsx', 'blog', [
148
+ page('blog/page.tsx', ''), // Generated path: /blog
149
+ page('blog/[id]/page.tsx', ':id'), // Generated path: /blog/:id
150
+ $('blog/$.tsx', '*'), // Wildcard route, matches all unmatched paths under /blog
151
151
  ]),
152
- ]
153
- })
152
+ ];
153
+ });
154
154
  ```
155
155
 
156
156
  **Use cases**:
@@ -170,11 +170,11 @@ The `$` function has the same functionality as the `$.tsx` file in convention ro
170
170
  export default defineRoutes(({ page }, fileRoutes) => {
171
171
  return [
172
172
  // Use page function to explicitly specify page route
173
- page("home.tsx", "/"),
174
- page("about.tsx", "about"),
175
- page("contact.tsx", "contact"),
176
- ]
177
- })
173
+ page('home.tsx', '/'),
174
+ page('about.tsx', 'about'),
175
+ page('contact.tsx', 'contact'),
176
+ ];
177
+ });
178
178
  ```
179
179
 
180
180
  ### Routes Without Path
@@ -186,12 +186,12 @@ export default defineRoutes(({ layout, page }, fileRoutes) => {
186
186
  return [
187
187
  // Use layout function to explicitly specify layout route
188
188
  // auth/layout.tsx needs to contain <Outlet> to render child routes
189
- layout("auth/layout.tsx", [
190
- page("login/page.tsx", "login"),
191
- page("register/page.tsx", "register"),
189
+ layout('auth/layout.tsx', [
190
+ page('login/page.tsx', 'login'),
191
+ page('register/page.tsx', 'register'),
192
192
  ]),
193
- ]
194
- })
193
+ ];
194
+ });
195
195
  ```
196
196
 
197
197
  The above configuration will generate:
@@ -204,11 +204,11 @@ The above configuration will generate:
204
204
  ```ts
205
205
  export default defineRoutes(({ page }, fileRoutes) => {
206
206
  return [
207
- page("user.tsx", "user"),
208
- page("user.tsx", "profile"),
209
- page("user.tsx", "account"),
210
- ]
211
- })
207
+ page('user.tsx', 'user'),
208
+ page('user.tsx', 'profile'),
209
+ page('user.tsx', 'account'),
210
+ ];
211
+ });
212
212
  ```
213
213
 
214
214
  ### Dynamic Routes
@@ -219,12 +219,12 @@ Config routes support dynamic route parameters:
219
219
  export default defineRoutes(({ page }, fileRoutes) => {
220
220
  return [
221
221
  // Required parameter
222
- page("blog/detail.tsx", "blog/:id"),
222
+ page('blog/detail.tsx', 'blog/:id'),
223
223
 
224
224
  // Optional parameter
225
- page("blog/index.tsx", "blog/:slug?"),
226
- ]
227
- })
225
+ page('blog/index.tsx', 'blog/:slug?'),
226
+ ];
227
+ });
228
228
  ```
229
229
 
230
230
  ## Automatic Route-Related File Discovery
@@ -235,10 +235,10 @@ Config routes automatically discover component-related files without manual conf
235
235
  // modern.routes.ts
236
236
  export default defineRoutes(({ route }, fileRoutes) => {
237
237
  return [
238
- route("pages/profile.tsx", "profile"),
239
- route("pages/user/detail.tsx", "user/:id"),
240
- ]
241
- })
238
+ route('pages/profile.tsx', 'profile'),
239
+ route('pages/user/detail.tsx', 'user/:id'),
240
+ ];
241
+ });
242
242
  ```
243
243
 
244
244
  Modern.js will automatically find and load:
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Routing
2
4
 
3
5
  Modern.js routing is based on [React Router v7](https://reactrouter.com/en/main), offering file convention-based routing capabilities and supporting the industry-popular **nested routing** pattern. When an entry is recognized as [conventional routing](/guides/concept/entries.md#conventional-routing), Modern.js automatically generates the corresponding routing structure based on the file system.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Import JSON Files
2
4
 
3
5
  Modern.js supports import JSON files in code by default. You can use Rsbuild plugins to support importing [YAML](https://yaml.org/) and [Toml](https://toml.io/en/) files and converting them to JSON format.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Import SVG Assets
2
4
 
3
5
  Modern.js supports import SVG assets and transform SVG into React components or URLs.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Import Wasm Assets
2
4
 
3
5
  Modern.js supports import WebAssembly assets in code.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Import Static Assets
2
4
 
3
5
  Modern.js supports import static assets, including images, fonts, and medias.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Playwright
2
4
 
3
5
  Playwright is a testing framework that allows you to run tests automatically in Chromium, Firefox, and WebKit environments using a single API. You can use it to **write E2E tests**.
@@ -83,18 +85,18 @@ export default Index;
83
85
  Next, add test cases to ensure the links on your pages work properly.
84
86
 
85
87
  ```ts title="tests/example.spec.ts"
86
- import { test, expect } from '@playwright/test'
88
+ import { test, expect } from '@playwright/test';
87
89
 
88
90
  test('should navigate to the about page', async ({ page }) => {
89
91
  // Start from the index page (the baseURL is set via the webServer in the playwright.config.ts)
90
- await page.goto('http://localhost:8080/')
92
+ await page.goto('http://localhost:8080/');
91
93
  // Find an element with the text 'About' and click on it
92
- await page.click('text=About')
94
+ await page.click('text=About');
93
95
  // The new URL should be "/about" (baseURL is used there)
94
- await expect(page).toHaveURL('http://localhost:8080/about')
96
+ await expect(page).toHaveURL('http://localhost:8080/about');
95
97
  // The new page should contain an h1 with "About"
96
- await expect(page.locator('h1')).toContainText('About')
97
- })
98
+ await expect(page.locator('h1')).toContainText('About');
99
+ });
98
100
  ```
99
101
 
100
102
  ## Run Test Cases
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Rstest
2
4
 
3
5
  [Rstest](https://rstest.rs) is a testing framework developed by the Rspack team and built on top of Rspack for fast test execution.
@@ -119,9 +121,9 @@ test('Page', async () => {
119
121
  </Router>,
120
122
  );
121
123
 
122
- await expect.element(
123
- page.getByRole('heading', { level: 1, name: 'Home' }),
124
- ).toBeVisible();
124
+ await expect
125
+ .element(page.getByRole('heading', { level: 1, name: 'Home' }))
126
+ .toBeVisible();
125
127
  });
126
128
  ```
127
129
 
@@ -231,8 +233,6 @@ For your Agent
231
233
 
232
234
  Migrate to Rstest
233
235
 
234
- Copy this prompt and send it to your coding agent.
235
-
236
236
  Copy Prompt
237
237
 
238
238
  Migrate this Modern.js project from Jest or Vitest to Rstest.
@@ -241,10 +241,12 @@ First install and use the migrate-to-rstest skill. If it is not installed, insta
241
241
  npx skills add rstackjs/agent-skills --skill migrate-to-rstest
242
242
 
243
243
  Follow the migrate-to-rstest skill instructions and the official Rstest migration guides:
244
+
244
245
  - Jest: https://rstest.rs/guide/migration/jest
245
246
  - Vitest: https://rstest.rs/guide/migration/vitest
246
247
 
247
248
  Modern.js-specific requirement:
249
+
248
250
  - Install and use @modern-js/adapter-rstest together with @rstest/core.
249
251
  - Create or update rstest.config.ts to import withModernConfig from @modern-js/adapter-rstest.
250
252
  - Reuse the Modern.js app configuration with extends: withModernConfig().
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Build Engine
2
4
 
3
5
  Modern.js internally encapsulates [Rsbuild](https://v2.rsbuild.rs/), using Rspack as the bundler.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Page Entry
2
4
 
3
5
  Through this chapter, you can understand the entry conventions in Modern.js and how to customize entries.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Web Server
2
4
 
3
5
  Modern.js provides an integrated Web server for applications that can run in any container environment with Node.js. Whether executing the `dev` command in a local development environment, running the `build && serve` commands in a production environment, or using the official deployment solution, it all runs through this Web server to host the application.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Modern.js For AI
2
4
 
3
5
  Modern.js provides a toolkit for AI agents that makes your project agent-ready out of the box, helping you use AI to develop, upgrade, and migrate Modern.js applications more accurately and efficiently.
@@ -10,10 +12,10 @@ AI agents use them to get APIs, config, and conventions that exactly match your
10
12
 
11
13
  ## AGENTS.md
12
14
 
13
- `AGENTS.md` gives AI coding agents project-level guidance — telling them to read the bundled docs before making changes and to follow Modern.js conventions. A `CLAUDE.md` is generated alongside it, reusing the same guidance for Claude Code via the `@AGENTS.md` import.
15
+ `AGENTS.md` gives AI coding agents project-level guidance — telling them to read the bundled docs before making changes and to follow Modern.js conventions.
14
16
 
15
- - **New projects**: `npx @modern-js/create` generates both files by default; pass `--no-agents-md` to skip them.
16
- - **Existing projects**: run `npx @modern-js/create --agents-md-only` at the project root to create or update them. Re-run it any time; your own additions are preserved.
17
+ - **New projects**: `npx @modern-js/create` generates `AGENTS.md` by default; pass `--no-agents-md` to skip it.
18
+ - **Existing projects**: run `npx @modern-js/create --agents-md-only` at the project root to create or update `AGENTS.md`. Re-run it any time; your own additions are preserved.
17
19
 
18
20
  Modern.js only maintains the content inside the `<!-- BEGIN:modernjs-agent-rules -->` markers in `AGENTS.md`; anything you write outside them is left untouched.
19
21
 
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Glossary
2
4
 
3
5
  ## BFF
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Introduction to Modern.js
2
4
 
3
5
  **Modern.js is a progressive web framework based on React**. At ByteDance, we use Modern.js to build upper-level frameworks that have supported the development of thousands of web applications.
@@ -1,10 +1,12 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Quick Start
2
4
 
3
5
  ## Environment
4
6
 
5
7
  ### Node.js
6
8
 
7
- Before getting started, you will need to install [Node.js](https://nodejs.org/), and ensure that your Node.js version is not lower than v20.19.5. **We recommend using the LTS version of Node.js 22.**
9
+ Before getting started, you will need to install [Node.js](https://nodejs.org/), and ensure that your Node.js version is not lower than v22.18.0. **We recommend using the LTS version of Node.js 22.**
8
10
 
9
11
  You can check the currently used Node.js version with the following command:
10
12
 
@@ -12,7 +14,7 @@ You can check the currently used Node.js version with the following command:
12
14
  node -v
13
15
  ```
14
16
 
15
- If you do not have Node.js installed in your current environment, or the installed version is lower than v20.19.5, you can use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install the required version.
17
+ If you do not have Node.js installed in your current environment, or the installed version does not meet this requirement, you can use [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to install the required version.
16
18
 
17
19
  Here is an example of how to install the Node.js 22 LTS version via nvm:
18
20
 
@@ -90,19 +92,18 @@ npx @modern-js/create@latest myapp
90
92
 
91
93
  ⚡ Start the development server:
92
94
 
93
- pnpm start
95
+ pnpm dev
94
96
  ```
95
97
 
96
98
  Now, the project structure is as follows:
97
99
 
98
100
  ```
99
101
  .
100
- ├── biome.json
101
102
  ├── modern.config.ts
102
103
  ├── package.json
103
104
  ├── README.md
105
+ ├── rstack.config.mts
104
106
  ├── src
105
- │ ├── modern-app-env.d.ts
106
107
  │ ├── modern.runtime.ts
107
108
  │ └── routes
108
109
  │ ├── index.css
@@ -111,6 +112,13 @@ Now, the project structure is as follows:
111
112
  └── tsconfig.json
112
113
  ```
113
114
 
115
+ New standalone projects use [Rstack CLI](https://rstack.rs/) for linting and formatting:
116
+
117
+ ```bash
118
+ pnpm check
119
+ pnpm format
120
+ ```
121
+
114
122
  ## Development
115
123
 
116
124
  Run `pnpm run dev` in the project to start the project:
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Tech Stack
2
4
 
3
5
  The Modern.js framework comes with built-in popular libraries and development tools from the community.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Upgrading
2
4
 
3
5
 
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Application-Level Modules
2
4
 
3
5
  Modern.js provides runtime APIs to quickly export application-level Module Federation modules from your application.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Deployment
2
4
 
3
5
  In general, when deploying a Module Federation application, there are two key points to consider:
@@ -63,9 +65,9 @@ At this point, the `publicPath` defined in the producer's build output `mf-manif
63
65
  "name": "remote",
64
66
  "publicPath": "https://my-remote-module/"
65
67
  },
66
- "shared": [ /* xxx */ ],
68
+ "shared": [/* xxx */],
67
69
  "remotes": [],
68
- "exposes": [ /* xxx */ ]
70
+ "exposes": [/* xxx */]
69
71
  }
70
72
  ```
71
73
 
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Integrating Internationalization
2
4
 
3
5
  Modern.js provides the **@modern-js/plugin-i18n** plugin to support internationalization. When using Module Federation, you need to provide corresponding i18n integration solutions for different scenarios (components or applications).
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Introduction
2
4
 
3
5
  Module Federation is an architectural pattern for dividing JavaScript applications, allowing you to share code and resources among multiple JavaScript applications.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Server-Side Rendering
2
4
 
3
5
  `@module-federation/modern-js-v3` offers powerful capabilities, enabling developers to easily combine Module Federation with server-side rendering (SSR) in Modern.js applications.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Getting Started
2
4
 
3
5
  To use Module Federation in Modern.js, we recommend using the official plugin `@module-federation/modern-js-v3`.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Build FAQ
2
4
 
3
5
  If you encounter any build-related issues, you can refer to the current document for troubleshooting.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # CLI FAQ
2
4
 
3
5
  ### Unable to pass command line arguments correctly when using pnpm?
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Dependencies FAQ
2
4
 
3
5
  ### How to check the actual installed version of a dependency in the project?
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # HMR FAQ
2
4
 
3
5
  ### How to troubleshooting HMR ineffective issues?
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Configuration Changes
2
4
 
3
5
  This document mainly introduces incompatible configuration changes and recommended migration methods when upgrading from Modern.js 2.0 to 3.0.
@@ -22,6 +24,18 @@ server: {
22
24
  }
23
25
  ```
24
26
 
27
+ ### dev.lazyCompilation
28
+
29
+ **Change**: The default value in development has changed. Pure CSR and streaming SSR applications enable lazy compilation by default with `{ imports: true, entries: false }`; applications using string SSR, RSC or SSG keep it disabled by default. This only affects development and does not change production build output.
30
+
31
+ **Migration Example**: To keep the 2.0 behavior, disable it explicitly:
32
+
33
+ ```typescript
34
+ dev: {
35
+ lazyCompilation: false;
36
+ }
37
+ ```
38
+
25
39
  ## html
26
40
 
27
41
  ### html.appIcon
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Entry Changes
2
4
 
3
5
  This chapter introduces changes related to page entries when upgrading from Modern.js 2.0 to 3.0.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Other Important Changes
2
4
 
3
5
  This document introduces other important incompatible changes and related migration instructions when upgrading from Modern.js 2.0 to 3.0.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Overview
2
4
 
3
5
  This guide will help you upgrade from Modern.js 2.0 to Modern.js 3.0.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Tailwind Plugin Changes
2
4
 
3
5
  Modern.js 3.0 recommends integrating Tailwind CSS through Rsbuild's native approach, no longer relying on the `@modern-js/plugin-tailwindcss` plugin, to fully utilize Rsbuild's more flexible configuration capabilities and better build experience.
@@ -1,3 +1,5 @@
1
+ > For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.
2
+
1
3
  # Custom Web Server Changes
2
4
 
3
5
  This chapter covers upgrades for two types of legacy custom Server APIs:
@@ -21,7 +23,10 @@ These two approaches are mutually exclusive in the legacy version. When migratin
21
23
 
22
24
  ```typescript
23
25
  // Legacy - server/index.ts
24
- export const unstableMiddleware: UnstableMiddleware[] = [middleware1, middleware2];
26
+ export const unstableMiddleware: UnstableMiddleware[] = [
27
+ middleware1,
28
+ middleware2,
29
+ ];
25
30
 
26
31
  // New - server/modern.server.ts
27
32
  import { defineServerConfig } from '@modern-js/server-runtime';
@@ -38,13 +43,22 @@ export default defineServerConfig({
38
43
 
39
44
  ```typescript
40
45
  // Legacy
41
- import type { UnstableMiddleware, UnstableMiddlewareContext } from '@modern-js/server-runtime';
42
- const middleware: UnstableMiddleware = async (c: UnstableMiddlewareContext, next) => {
46
+ import type {
47
+ UnstableMiddleware,
48
+ UnstableMiddlewareContext,
49
+ } from '@modern-js/server-runtime';
50
+ const middleware: UnstableMiddleware = async (
51
+ c: UnstableMiddlewareContext,
52
+ next,
53
+ ) => {
43
54
  return c.response.raw('response'); // Will continue rendering even without calling next
44
55
  };
45
56
 
46
57
  // New
47
- import { defineServerConfig, type MiddlewareHandler } from '@modern-js/server-runtime';
58
+ import {
59
+ defineServerConfig,
60
+ type MiddlewareHandler,
61
+ } from '@modern-js/server-runtime';
48
62
  const middleware: MiddlewareHandler = async (c, next) => {
49
63
  await next(); // Must call
50
64
  return c.text('response');
@@ -88,7 +102,10 @@ export const afterRender = (ctx, next) => {
88
102
  };
89
103
 
90
104
  // New - server/modern.server.ts
91
- import { defineServerConfig, type MiddlewareHandler } from '@modern-js/server-runtime';
105
+ import {
106
+ defineServerConfig,
107
+ type MiddlewareHandler,
108
+ } from '@modern-js/server-runtime';
92
109
 
93
110
  const renderMiddleware: MiddlewareHandler = async (c, next) => {
94
111
  await next(); // Wait for page rendering first
@@ -104,6 +121,8 @@ const renderMiddleware: MiddlewareHandler = async (c, next) => {
104
121
  };
105
122
 
106
123
  export default defineServerConfig({
107
- renderMiddlewares: [{ name: 'custom-content-injection', handler: renderMiddleware }],
124
+ renderMiddlewares: [
125
+ { name: 'custom-content-injection', handler: renderMiddleware },
126
+ ],
108
127
  });
109
128
  ```