@modern-js/app-tools 3.9.2 → 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.
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +54 -2
- package/dist/cjs/commands/build.js +1 -2
- package/dist/cjs/commands/deploy.js +1 -3
- package/dist/cjs/commands/index.js +4 -0
- package/dist/cjs/compat/hooks.js +0 -5
- package/dist/cjs/compat/index.js +0 -5
- package/dist/cjs/compat/utils.js +0 -5
- package/dist/cjs/index.js +15 -39
- package/dist/cjs/plugins/analyze/index.js +2 -2
- package/dist/cjs/plugins/analyze/utils.js +2 -3
- package/dist/cjs/plugins/initialize/index.js +3 -5
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +54 -2
- package/dist/esm/commands/build.mjs +1 -2
- package/dist/esm/commands/deploy.mjs +1 -3
- package/dist/esm/commands/index.mjs +4 -0
- package/dist/esm/compat/hooks.mjs +0 -5
- package/dist/esm/compat/index.mjs +0 -5
- package/dist/esm/compat/utils.mjs +0 -5
- package/dist/esm/index.mjs +2 -10
- package/dist/esm/plugins/analyze/index.mjs +2 -2
- package/dist/esm/plugins/analyze/utils.mjs +2 -3
- package/dist/esm/plugins/initialize/index.mjs +3 -5
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.mjs +54 -2
- package/dist/esm-node/commands/build.mjs +1 -2
- package/dist/esm-node/commands/deploy.mjs +1 -3
- package/dist/esm-node/commands/index.mjs +4 -0
- package/dist/esm-node/compat/hooks.mjs +0 -5
- package/dist/esm-node/compat/index.mjs +0 -5
- package/dist/esm-node/compat/utils.mjs +0 -5
- package/dist/esm-node/index.mjs +2 -10
- package/dist/esm-node/plugins/analyze/index.mjs +2 -2
- package/dist/esm-node/plugins/analyze/utils.mjs +2 -3
- package/dist/esm-node/plugins/initialize/index.mjs +3 -5
- package/dist/types/index.d.ts +1 -3
- package/dist/types/plugins/analyze/utils.d.ts +1 -1
- package/dist/types/types/config/index.d.ts +0 -2
- package/dist/types/types/config/tools.d.ts +0 -8
- package/docs/apis/app/commands.md +2 -0
- package/docs/apis/app/hooks/api/lambda.md +2 -0
- package/docs/apis/app/hooks/config/favicon.md +2 -0
- package/docs/apis/app/hooks/config/html.md +2 -0
- package/docs/apis/app/hooks/config/icon.md +2 -0
- package/docs/apis/app/hooks/config/mock.md +2 -0
- package/docs/apis/app/hooks/config/public.md +2 -0
- package/docs/apis/app/hooks/config/upload.md +3 -3
- package/docs/apis/app/hooks/modern-config.md +2 -0
- package/docs/apis/app/hooks/server/server.md +2 -0
- package/docs/apis/app/hooks/shared.md +2 -0
- package/docs/apis/app/hooks/src/app.md +2 -0
- package/docs/apis/app/hooks/src/entry.md +2 -0
- package/docs/apis/app/hooks/src/entry.server.md +2 -0
- package/docs/apis/app/hooks/src/modern.runtime.md +2 -0
- package/docs/apis/app/hooks/src/routes.md +2 -0
- package/docs/apis/app/hooks/src/server.md +2 -0
- package/docs/apis/app/runtime/bff/use-hono-context.md +2 -0
- package/docs/apis/app/runtime/core/create-root.md +5 -1
- package/docs/apis/app/runtime/core/render.md +7 -2
- package/docs/apis/app/runtime/core/runtime-context.md +18 -16
- package/docs/apis/app/runtime/router/router.md +11 -6
- package/docs/apis/app/runtime/ssr/no-ssr.md +2 -0
- package/docs/apis/app/runtime/ssr/renderStreaming.md +2 -0
- package/docs/apis/app/runtime/ssr/renderString.md +2 -0
- package/docs/apis/app/runtime/ssr/requestHandler.md +2 -0
- package/docs/apis/app/runtime/utility/css-in-js.md +2 -0
- package/docs/apis/app/runtime/utility/head.md +2 -0
- package/docs/apis/app/runtime/utility/loadable.md +2 -0
- package/docs/community/blog/2022-0708-updates.md +2 -0
- package/docs/community/blog/2022-0910-updates.md +2 -0
- package/docs/community/blog/overview.md +2 -0
- package/docs/community/blog/v2-release-note.md +2 -0
- package/docs/community/blog/v3-release-note.md +18 -13
- package/docs/community/contributing-guide.md +17 -33
- package/docs/community/releases.md +2 -0
- package/docs/community/showcase.md +2 -0
- package/docs/community/team.md +2 -0
- package/docs/configure/app/bff/cross-project.md +2 -0
- package/docs/configure/app/bff/prefix.md +2 -0
- package/docs/configure/app/builder-plugins.md +2 -0
- package/docs/configure/app/dev/asset-prefix.md +2 -0
- package/docs/configure/app/dev/before-start-url.md +2 -0
- package/docs/configure/app/dev/client.md +2 -0
- package/docs/configure/app/dev/hmr.md +2 -0
- package/docs/configure/app/dev/host.md +2 -0
- package/docs/configure/app/dev/https.md +2 -0
- package/docs/configure/app/dev/lazy-compilation.md +19 -1
- package/docs/configure/app/dev/live-reload.md +2 -0
- package/docs/configure/app/dev/mock-dir.md +2 -0
- package/docs/configure/app/dev/progress-bar.md +2 -0
- package/docs/configure/app/dev/server.md +2 -0
- package/docs/configure/app/dev/setup-middlewares.md +2 -0
- package/docs/configure/app/dev/start-url.md +2 -0
- package/docs/configure/app/dev/watch-files.md +2 -0
- package/docs/configure/app/dev/write-to-disk.md +2 -0
- package/docs/configure/app/experiments/source-build.md +2 -0
- package/docs/configure/app/html/app-icon.md +2 -0
- package/docs/configure/app/html/crossorigin.md +2 -0
- package/docs/configure/app/html/favicon.md +2 -0
- package/docs/configure/app/html/inject.md +2 -0
- package/docs/configure/app/html/meta.md +2 -0
- package/docs/configure/app/html/mount-id.md +2 -0
- package/docs/configure/app/html/output-structure.md +2 -0
- package/docs/configure/app/html/script-loading.md +2 -0
- package/docs/configure/app/html/tags.md +2 -0
- package/docs/configure/app/html/template-parameters.md +2 -0
- package/docs/configure/app/html/template.md +2 -0
- package/docs/configure/app/html/title.md +2 -0
- package/docs/configure/app/output/asset-prefix.md +2 -0
- package/docs/configure/app/output/assets-retry.md +2 -0
- package/docs/configure/app/output/charset.md +2 -0
- package/docs/configure/app/output/clean-dist-path.md +2 -0
- package/docs/configure/app/output/convert-to-rem.md +2 -0
- package/docs/configure/app/output/copy.md +2 -0
- package/docs/configure/app/output/css-modules.md +3 -5
- package/docs/configure/app/output/data-uri-limit.md +2 -0
- package/docs/configure/app/output/disable-css-module-extension.md +2 -0
- package/docs/configure/app/output/disable-inline-runtime-chunk.md +2 -0
- package/docs/configure/app/output/disable-svgr.md +6 -0
- package/docs/configure/app/output/disable-ts-checker.md +2 -0
- package/docs/configure/app/output/dist-path.md +2 -0
- package/docs/configure/app/output/enable-asset-manifest.md +2 -0
- package/docs/configure/app/output/enable-css-module-tsdeclaration.md +2 -0
- package/docs/configure/app/output/enable-inline-route-manifests.md +2 -0
- package/docs/configure/app/output/externals.md +2 -0
- package/docs/configure/app/output/filename-hash.md +2 -0
- package/docs/configure/app/output/filename.md +2 -0
- package/docs/configure/app/output/inject-styles.md +2 -0
- package/docs/configure/app/output/inline-scripts.md +3 -2
- package/docs/configure/app/output/inline-styles.md +3 -2
- package/docs/configure/app/output/legal-comments.md +2 -0
- package/docs/configure/app/output/minify.md +2 -0
- package/docs/configure/app/output/override-browserslist.md +2 -0
- package/docs/configure/app/output/polyfill.md +2 -0
- package/docs/configure/app/output/source-map.md +2 -0
- package/docs/configure/app/output/split-route-chunks.md +3 -1
- package/docs/configure/app/output/ssg.md +2 -0
- package/docs/configure/app/output/ssgByEntries.md +2 -0
- package/docs/configure/app/output/svg-default-export.md +6 -0
- package/docs/configure/app/output/temp-dir.md +2 -0
- package/docs/configure/app/performance/build-cache.md +2 -0
- package/docs/configure/app/performance/chunk-split.md +3 -4
- package/docs/configure/app/performance/dns-prefetch.md +2 -0
- package/docs/configure/app/performance/preconnect.md +2 -0
- package/docs/configure/app/performance/prefetch.md +2 -0
- package/docs/configure/app/performance/preload.md +2 -0
- package/docs/configure/app/performance/print-file-size.md +2 -0
- package/docs/configure/app/performance/profile.md +2 -0
- package/docs/configure/app/performance/remove-console.md +2 -0
- package/docs/configure/app/performance/remove-moment-locale.md +2 -0
- package/docs/configure/app/plugins.md +2 -0
- package/docs/configure/app/resolve/alias-strategy.md +2 -0
- package/docs/configure/app/resolve/alias.md +2 -0
- package/docs/configure/app/resolve/condition-names.md +2 -0
- package/docs/configure/app/resolve/dedupe.md +2 -0
- package/docs/configure/app/resolve/extensions.md +2 -0
- package/docs/configure/app/runtime/0-intro.md +2 -0
- package/docs/configure/app/runtime/plugins.md +8 -4
- package/docs/configure/app/runtime/router.md +2 -0
- package/docs/configure/app/security/check-syntax.md +2 -0
- package/docs/configure/app/security/nonce.md +2 -0
- package/docs/configure/app/security/sri.md +2 -0
- package/docs/configure/app/server/base-url.md +2 -0
- package/docs/configure/app/server/port.md +2 -0
- package/docs/configure/app/server/public-routes.md +2 -0
- package/docs/configure/app/server/routes.md +2 -0
- package/docs/configure/app/server/rsc.md +2 -0
- package/docs/configure/app/server/ssr-by-entries.md +2 -0
- package/docs/configure/app/server/ssr.md +3 -1
- package/docs/configure/app/server/tsconfig-path.md +4 -2
- package/docs/configure/app/source/alias-strategy.md +2 -0
- package/docs/configure/app/source/alias.md +2 -0
- package/docs/configure/app/source/config-dir.md +2 -0
- package/docs/configure/app/source/decorators.md +2 -0
- package/docs/configure/app/source/define.md +2 -0
- package/docs/configure/app/source/disable-default-entries.md +2 -0
- package/docs/configure/app/source/enable-async-entry.md +2 -0
- package/docs/configure/app/source/enable-async-pre-entry.md +2 -0
- package/docs/configure/app/source/entries-dir.md +2 -0
- package/docs/configure/app/source/entries.md +2 -0
- package/docs/configure/app/source/exclude.md +2 -0
- package/docs/configure/app/source/global-vars.md +2 -0
- package/docs/configure/app/source/include.md +2 -0
- package/docs/configure/app/source/main-entry-name.md +2 -0
- package/docs/configure/app/source/pre-entry.md +2 -0
- package/docs/configure/app/source/react-compiler.md +2 -0
- package/docs/configure/app/source/transform-import.md +2 -0
- package/docs/configure/app/split-chunks.md +2 -0
- package/docs/configure/app/tools/autoprefixer.md +2 -0
- package/docs/configure/app/tools/bundler-chain.md +2 -0
- package/docs/configure/app/tools/css-extract.md +2 -0
- package/docs/configure/app/tools/css-loader.md +2 -0
- package/docs/configure/app/tools/dev-server.md +2 -0
- package/docs/configure/app/tools/html-plugin.md +2 -0
- package/docs/configure/app/tools/less.md +96 -19
- package/docs/configure/app/tools/lightningcss-loader.md +2 -0
- package/docs/configure/app/tools/minify-css.md +2 -0
- package/docs/configure/app/tools/postcss.md +2 -0
- package/docs/configure/app/tools/rspack.md +2 -0
- package/docs/configure/app/tools/sass.md +89 -18
- package/docs/configure/app/tools/style-loader.md +2 -0
- package/docs/configure/app/tools/svgr.md +91 -0
- package/docs/configure/app/tools/swc.md +2 -0
- package/docs/configure/app/tools/ts-checker.md +2 -0
- package/docs/configure/app/usage.md +3 -5
- package/docs/guides/advanced-features/bff/cross-project.md +6 -4
- package/docs/guides/advanced-features/bff/extend-server.md +2 -0
- package/docs/guides/advanced-features/bff/frameworks.md +2 -0
- package/docs/guides/advanced-features/bff/function.md +2 -0
- package/docs/guides/advanced-features/bff/operators.md +2 -0
- package/docs/guides/advanced-features/bff/sdk.md +2 -0
- package/docs/guides/advanced-features/bff/upload.md +2 -0
- package/docs/guides/advanced-features/bff.md +2 -0
- package/docs/guides/advanced-features/build-performance.md +2 -0
- package/docs/guides/advanced-features/compatibility.md +2 -0
- package/docs/guides/advanced-features/international/advanced.md +3 -1
- package/docs/guides/advanced-features/international/api.md +21 -13
- package/docs/guides/advanced-features/international/best-practices.md +17 -15
- package/docs/guides/advanced-features/international/configuration.md +3 -1
- package/docs/guides/advanced-features/international/locale-detection.md +15 -4
- package/docs/guides/advanced-features/international/quick-start.md +2 -0
- package/docs/guides/advanced-features/international/resource-loading.md +11 -7
- package/docs/guides/advanced-features/international/routing.md +5 -1
- package/docs/guides/advanced-features/international.md +2 -0
- package/docs/guides/advanced-features/low-level.md +2 -0
- package/docs/guides/advanced-features/page-performance/code-split.md +2 -0
- package/docs/guides/advanced-features/page-performance/inline-assets.md +2 -0
- package/docs/guides/advanced-features/page-performance/optimize-bundle.md +2 -0
- package/docs/guides/advanced-features/page-performance/react-compiler.md +2 -0
- package/docs/guides/advanced-features/server-monitor/logger.md +2 -0
- package/docs/guides/advanced-features/server-monitor/metrics.md +2 -0
- package/docs/guides/advanced-features/server-monitor/monitors.md +3 -3
- package/docs/guides/advanced-features/source-build.md +3 -1
- package/docs/guides/advanced-features/web-server.md +5 -3
- package/docs/guides/basic-features/alias.md +2 -0
- package/docs/guides/basic-features/css/css-in-js.md +2 -0
- package/docs/guides/basic-features/css/css-modules.md +2 -0
- package/docs/guides/basic-features/css/css.md +2 -0
- package/docs/guides/basic-features/css/tailwindcss.md +2 -0
- package/docs/guides/basic-features/data/data-cache.md +2 -0
- package/docs/guides/basic-features/data/data-fetch.md +3 -3
- package/docs/guides/basic-features/data/data-write.md +25 -28
- package/docs/guides/basic-features/debug/mock.md +4 -2
- package/docs/guides/basic-features/debug/proxy.md +2 -0
- package/docs/guides/basic-features/debug/rsdoctor.md +2 -0
- package/docs/guides/basic-features/debug/using-storybook.md +6 -4
- package/docs/guides/basic-features/deploy.md +2 -0
- package/docs/guides/basic-features/env-vars.md +2 -0
- package/docs/guides/basic-features/html.md +4 -3
- package/docs/guides/basic-features/output-files.md +3 -1
- package/docs/guides/basic-features/render/before-render.md +2 -0
- package/docs/guides/basic-features/render/overview.md +2 -0
- package/docs/guides/basic-features/render/rsc.md +12 -2
- package/docs/guides/basic-features/render/ssg.md +2 -0
- package/docs/guides/basic-features/render/ssr-cache.md +2 -0
- package/docs/guides/basic-features/render/ssr.md +10 -12
- package/docs/guides/basic-features/render/streaming-ssr.md +4 -1
- package/docs/guides/basic-features/routes/config-routes.md +54 -54
- package/docs/guides/basic-features/routes/routes.md +2 -0
- package/docs/guides/basic-features/static-assets/json-files.md +2 -0
- package/docs/guides/basic-features/static-assets/svg-assets.md +31 -17
- package/docs/guides/basic-features/static-assets/wasm-assets.md +2 -0
- package/docs/guides/basic-features/static-assets.md +2 -0
- package/docs/guides/basic-features/testing/playwright.md +8 -6
- package/docs/guides/basic-features/testing/rstest.md +7 -5
- package/docs/guides/concept/builder.md +2 -0
- package/docs/guides/concept/entries.md +2 -0
- package/docs/guides/concept/server.md +2 -0
- package/docs/guides/get-started/ai-coding-agents.md +5 -3
- package/docs/guides/get-started/glossary.md +2 -0
- package/docs/guides/get-started/introduction.md +2 -0
- package/docs/guides/get-started/quick-start.md +13 -5
- package/docs/guides/get-started/tech-stack.md +2 -0
- package/docs/guides/get-started/upgrade.md +2 -0
- package/docs/guides/topic-detail/module-federation/application.md +2 -0
- package/docs/guides/topic-detail/module-federation/deploy.md +4 -2
- package/docs/guides/topic-detail/module-federation/i18n.md +2 -0
- package/docs/guides/topic-detail/module-federation/introduce.md +2 -0
- package/docs/guides/topic-detail/module-federation/ssr.md +2 -0
- package/docs/guides/topic-detail/module-federation/usage.md +2 -0
- package/docs/guides/troubleshooting/builder.md +2 -0
- package/docs/guides/troubleshooting/cli.md +2 -0
- package/docs/guides/troubleshooting/dependencies.md +2 -0
- package/docs/guides/troubleshooting/hmr.md +2 -0
- package/docs/guides/upgrade/config.md +14 -0
- package/docs/guides/upgrade/entry.md +2 -0
- package/docs/guides/upgrade/other.md +2 -0
- package/docs/guides/upgrade/overview.md +2 -0
- package/docs/guides/upgrade/tailwindcss.md +2 -0
- package/docs/guides/upgrade/web-server.md +25 -6
- package/docs/index.md +2 -0
- package/docs/llms.txt +8 -7
- package/docs/plugin/cli-plugins/api.md +2 -0
- package/docs/plugin/cli-plugins/life-cycle.md +2 -0
- package/docs/plugin/introduction.md +12 -10
- package/docs/plugin/official/cli-plugins/plugin-bff.md +2 -0
- package/docs/plugin/official/cli-plugins/plugin-ssg.md +2 -0
- package/docs/plugin/official/cli-plugins/plugin-styled-components.md +2 -0
- package/docs/plugin/official/cli-plugins.md +2 -0
- package/docs/plugin/plugin-system.md +3 -3
- package/docs/plugin/runtime-plugins/api.md +2 -0
- package/docs/plugin/runtime-plugins/life-cycle.md +2 -0
- package/docs/plugin/server-plugins/api.md +2 -0
- package/docs/plugin/server-plugins/life-cycle.md +2 -0
- package/docs/tutorials/examples/csr-auth.md +2 -0
- package/docs/tutorials/foundations/introduction.md +2 -0
- package/lib/types.d.ts +0 -1
- package/package.json +18 -19
- package/{rslib.config.mts → rstack.config.mts} +4 -4
- package/dist/cjs/types/config/testing.js +0 -18
- package/dist/esm/types/config/testing.mjs +0 -0
- package/dist/esm-node/types/config/testing.mjs +0 -1
- 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
|
# Rendering Mode Overview
|
|
2
4
|
|
|
3
5
|
Modern.js supports multiple rendering modes, and different rendering modes are suitable for different scenarios. Choosing the right rendering mode can significantly improve application performance and user 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
|
# React Server Components (RSC)
|
|
2
4
|
|
|
3
5
|
React Server Components (RSC) is a new component type that allows components to be rendered in a server environment, bringing better performance and developer experience to modern web applications.
|
|
@@ -264,7 +266,11 @@ In Modern.js RSC projects, Server Components can receive data returned by Data L
|
|
|
264
266
|
|
|
265
267
|
```tsx title="routes/user/page.tsx"
|
|
266
268
|
// Server Component receives loaderData through props
|
|
267
|
-
export default function UserPage({
|
|
269
|
+
export default function UserPage({
|
|
270
|
+
loaderData,
|
|
271
|
+
}: {
|
|
272
|
+
loaderData: { name: string };
|
|
273
|
+
}) {
|
|
268
274
|
return <div>Welcome, {loaderData.name}</div>;
|
|
269
275
|
}
|
|
270
276
|
```
|
|
@@ -272,7 +278,11 @@ export default function UserPage({ loaderData }: { loaderData: { name: string }
|
|
|
272
278
|
```tsx title="routes/user/page.tsx"
|
|
273
279
|
'use client';
|
|
274
280
|
// Client Component can also receive loaderData through props
|
|
275
|
-
export default function UserPage({
|
|
281
|
+
export default function UserPage({
|
|
282
|
+
loaderData,
|
|
283
|
+
}: {
|
|
284
|
+
loaderData: { name: string };
|
|
285
|
+
}) {
|
|
276
286
|
return <div>Welcome, {loaderData.name}</div>;
|
|
277
287
|
}
|
|
278
288
|
```
|
|
@@ -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
|
# Static Site Generation
|
|
2
4
|
|
|
3
5
|
SSG (Static Site Generation) is a technical solution that generates complete static web pages at build time based on data and templates. This means that in a production environment, pages are pre-rendered with content and can be cached by a CDN. SSG can offer better performance and higher security for pages that do not require dynamic data.
|
|
@@ -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
|
# Rendering Cache
|
|
2
4
|
|
|
3
5
|
When developing applications, sometimes we cache computation results using hooks like React's `useMemo` and `useCallback`. By leveraging caching, we can reduce the number of computations, thus saving CPU resources and improving user 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
|
# Server-Side Rendering
|
|
2
4
|
|
|
3
5
|
Server-Side Rendering (SSR) generates complete HTML pages on the server and sends them to the browser for direct display, without requiring additional client-side rendering.
|
|
@@ -90,7 +92,7 @@ export async function loader({ params }) {
|
|
|
90
92
|
const data = await res.json();
|
|
91
93
|
return {
|
|
92
94
|
message: data.message,
|
|
93
|
-
}
|
|
95
|
+
};
|
|
94
96
|
}
|
|
95
97
|
```
|
|
96
98
|
|
|
@@ -124,11 +126,7 @@ const Page = () => {
|
|
|
124
126
|
const undefinedVars = data.unDefined;
|
|
125
127
|
const definedVars = data.defined;
|
|
126
128
|
|
|
127
|
-
return
|
|
128
|
-
<div>
|
|
129
|
-
{isNode ? undefinedVars.msg : definedVars.msg}
|
|
130
|
-
</div>
|
|
131
|
-
);
|
|
129
|
+
return <div>{isNode ? undefinedVars.msg : definedVars.msg}</div>;
|
|
132
130
|
};
|
|
133
131
|
|
|
134
132
|
export default Page;
|
|
@@ -212,7 +210,7 @@ document.addEventListener('load', () => {
|
|
|
212
210
|
console.log('document load');
|
|
213
211
|
});
|
|
214
212
|
|
|
215
|
-
export const doSomething = () => {}
|
|
213
|
+
export const doSomething = () => {};
|
|
216
214
|
```
|
|
217
215
|
|
|
218
216
|
Directly referencing this in a component will cause SSR to throw errors, even if you use environment variables to conditionally load the code. The side effects in the dependency will still execute.
|
|
@@ -224,8 +222,8 @@ export const Page = () => {
|
|
|
224
222
|
if (process.env.MODERN_TARGET === 'browser') {
|
|
225
223
|
doSomething();
|
|
226
224
|
}
|
|
227
|
-
return <div>Hello World</div
|
|
228
|
-
}
|
|
225
|
+
return <div>Hello World</div>;
|
|
226
|
+
};
|
|
229
227
|
```
|
|
230
228
|
|
|
231
229
|
Modern.js supports distinguishing between SSR and CSR bundles by using `.server.` suffix files. You can create `.ts` and `.server.ts` files with the same name to create a proxy:
|
|
@@ -241,12 +239,12 @@ export const doSomething: any = () => {};
|
|
|
241
239
|
Import `./a` in the file, and the SSR bundle will prioritize the `.server.ts` files, while the CSR bundle will prioritize the `.ts` files.
|
|
242
240
|
|
|
243
241
|
```tsx title="routes/page.tsx"
|
|
244
|
-
import { doSomething } from './a'
|
|
242
|
+
import { doSomething } from './a';
|
|
245
243
|
|
|
246
244
|
export const Page = () => {
|
|
247
245
|
doSomething();
|
|
248
|
-
return <div>Hello World</div
|
|
249
|
-
}
|
|
246
|
+
return <div>Hello World</div>;
|
|
247
|
+
};
|
|
250
248
|
```
|
|
251
249
|
|
|
252
250
|
## Common 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
|
# Streaming Server-Side Rendering
|
|
2
4
|
|
|
3
5
|
Streaming rendering is an advanced rendering method that progressively returns content during the page rendering process, significantly improving user experience.
|
|
@@ -245,7 +247,8 @@ Set the header in your middleware to choose the behavior dynamically:
|
|
|
245
247
|
```ts title="middleware example"
|
|
246
248
|
export const middleware = async (ctx, next) => {
|
|
247
249
|
const ua = ctx.req.header('user-agent') || '';
|
|
248
|
-
const shouldWaitAll =
|
|
250
|
+
const shouldWaitAll =
|
|
251
|
+
/Lighthouse|Googlebot/i.test(ua) || ctx.req.path === '/marketing';
|
|
249
252
|
|
|
250
253
|
// Write a boolean string: true -> onAllReady, false -> onShellReady
|
|
251
254
|
ctx.req.headers.set('x-should-stream-all', String(shouldWaitAll));
|
|
@@ -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
|
-
|
|
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(
|
|
73
|
-
route(
|
|
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(
|
|
78
|
-
route(
|
|
79
|
-
route(
|
|
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(
|
|
83
|
+
route('products/detail.tsx', 'products/:id'),
|
|
84
84
|
|
|
85
85
|
// Multiple paths pointing to the same component
|
|
86
|
-
route(
|
|
87
|
-
route(
|
|
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(
|
|
106
|
-
page(
|
|
107
|
-
page(
|
|
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(
|
|
127
|
-
page(
|
|
128
|
-
page(
|
|
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(
|
|
148
|
-
page(
|
|
149
|
-
page(
|
|
150
|
-
$(
|
|
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(
|
|
174
|
-
page(
|
|
175
|
-
page(
|
|
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(
|
|
190
|
-
page(
|
|
191
|
-
page(
|
|
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(
|
|
208
|
-
page(
|
|
209
|
-
page(
|
|
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(
|
|
222
|
+
page('blog/detail.tsx', 'blog/:id'),
|
|
223
223
|
|
|
224
224
|
// Optional parameter
|
|
225
|
-
page(
|
|
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(
|
|
239
|
-
route(
|
|
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.
|
|
@@ -38,16 +40,22 @@ export default () => <Logo />;
|
|
|
38
40
|
|
|
39
41
|
## Modify the Default Export
|
|
40
42
|
|
|
41
|
-
You can modify the default export of SVG files through
|
|
43
|
+
You can modify the default export of SVG files through `svgrOptions.exportType` of [tools.svgr](/configure/app/tools/svgr.md). For example, set the default export as a React component:
|
|
42
44
|
|
|
43
45
|
```ts
|
|
44
46
|
export default {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
tools: {
|
|
48
|
+
svgr: {
|
|
49
|
+
svgrOptions: {
|
|
50
|
+
exportType: 'default',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
47
53
|
},
|
|
48
54
|
};
|
|
49
55
|
```
|
|
50
56
|
|
|
57
|
+
The legacy [output.svgDefaultExport](/configure/app/output/svg-default-export.md) config still works but is deprecated.
|
|
58
|
+
|
|
51
59
|
Then import the SVG, you'll get a React component instead of a URL:
|
|
52
60
|
|
|
53
61
|
```tsx title="src/component/Logo.tsx"
|
|
@@ -74,12 +82,12 @@ Please read the [Import Static Assets](/guides/basic-features/static-assets.md)
|
|
|
74
82
|
|
|
75
83
|
## Disable SVGR Processing
|
|
76
84
|
|
|
77
|
-
By default, when an SVG resource is referenced in a JS file, Modern.js will call SVGR to convert the SVG into a React component. If you are sure that all SVG resources in your project are not being used as React components, you can turn off this conversion by setting [
|
|
85
|
+
By default, when an SVG resource is referenced in a JS file, Modern.js will call SVGR to convert the SVG into a React component. If you are sure that all SVG resources in your project are not being used as React components, you can turn off this conversion by setting [tools.svgr](/configure/app/tools/svgr.md) to `false` to improve build performance.
|
|
78
86
|
|
|
79
87
|
```js
|
|
80
88
|
export default {
|
|
81
|
-
|
|
82
|
-
|
|
89
|
+
tools: {
|
|
90
|
+
svgr: false,
|
|
83
91
|
},
|
|
84
92
|
};
|
|
85
93
|
```
|
|
@@ -147,21 +155,27 @@ When SVGR is enabled, its default configuration is as follows:
|
|
|
147
155
|
}
|
|
148
156
|
```
|
|
149
157
|
|
|
150
|
-
|
|
158
|
+
To modify the SVGR configuration, use `svgrOptions` of [tools.svgr](/configure/app/tools/svgr.md). The `svgoConfig.plugins` you pass are deep merged with the defaults by plugin name, so only the changed part needs to be written:
|
|
151
159
|
|
|
152
160
|
```js
|
|
153
161
|
export default {
|
|
154
162
|
tools: {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
svgr: {
|
|
164
|
+
svgrOptions: {
|
|
165
|
+
svgoConfig: {
|
|
166
|
+
plugins: [
|
|
167
|
+
{
|
|
168
|
+
name: 'preset-default',
|
|
169
|
+
params: {
|
|
170
|
+
overrides: {
|
|
171
|
+
// add one more override on top of the default preset-default
|
|
172
|
+
removeUselessDefs: false,
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
165
179
|
},
|
|
166
180
|
},
|
|
167
181
|
};
|
|
@@ -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
|
|
123
|
-
page.getByRole('heading', { level: 1, name: 'Home' })
|
|
124
|
-
|
|
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
|
# 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.
|
|
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
|
|
16
|
-
- **Existing projects**: run `npx @modern-js/create --agents-md-only` at the project root to create or update
|
|
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
|
# 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
|
|
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
|
|
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
|
|
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:
|