@modern-js/app-tools 3.6.0 → 3.8.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/bin/modern-bundle-docs.js +7 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +5 -1
- 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 +52 -14
- package/dist/cjs/plugins/analyze/index.js +2 -2
- package/dist/cjs/plugins/analyze/utils.js +3 -2
- package/dist/cjs/plugins/initialize/index.js +4 -3
- package/dist/cjs/plugins/serverBuild.js +3 -2
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +5 -1
- 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/initialize/index.mjs +4 -3
- package/dist/esm/plugins/serverBuild.mjs +3 -2
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +5 -1
- 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/initialize/index.mjs +4 -3
- package/dist/esm-node/plugins/serverBuild.mjs +3 -2
- 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/types/config/dev.d.ts +6 -0
- package/docs/apis/app/commands.md +241 -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-hono-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 +280 -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 +253 -0
- package/docs/community/releases.md +27 -0
- package/docs/community/showcase.md +34 -0
- package/docs/community/team.md +14 -0
- package/docs/configure/app/bff/cross-project.md +20 -0
- package/docs/configure/app/bff/prefix.md +29 -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 +16 -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 +39 -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/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 +26 -0
- package/docs/configure/app/server/ssr-by-entries.md +25 -0
- package/docs/configure/app/server/ssr.md +78 -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 +109 -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/extend-server.md +120 -0
- package/docs/guides/advanced-features/bff/frameworks.md +124 -0
- package/docs/guides/advanced-features/bff/function.md +314 -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 +231 -0
- package/docs/guides/advanced-features/international/best-practices.md +286 -0
- package/docs/guides/advanced-features/international/configuration.md +227 -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 +130 -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 +69 -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 +62 -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 +525 -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 +498 -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 +36 -0
- package/docs/guides/get-started/quick-start.md +236 -0
- package/docs/guides/get-started/tech-stack.md +82 -0
- package/docs/guides/get-started/upgrade.md +123 -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 +118 -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 +963 -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 +285 -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 +48 -15
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Modern.js For AI
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Bundled docs
|
|
6
|
+
|
|
7
|
+
Modern.js ships the English docs that match your installed version together with `@modern-js/app-tools`. After you install or upgrade, they live at `node_modules/@modern-js/app-tools/docs/`, available offline with no extra setup.
|
|
8
|
+
|
|
9
|
+
AI agents use them to get APIs, config, and conventions that exactly match your framework version, rather than relying on potentially outdated training data.
|
|
10
|
+
|
|
11
|
+
## AGENTS.md
|
|
12
|
+
|
|
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.
|
|
14
|
+
|
|
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
|
+
|
|
18
|
+
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
|
+
|
|
20
|
+
## llms.txt
|
|
21
|
+
|
|
22
|
+
llms.txt is an online documentation index following the [llms.txt specification](https://llmstxt.org/), auto-generated by [`@rspress/plugin-llms`](https://rspress.rs/plugin/official-plugins/llms) for AI tools to retrieve the full docs online:
|
|
23
|
+
|
|
24
|
+
- Index: [`https://modernjs.dev/llms.txt`](https://modernjs.dev/llms.txt)
|
|
25
|
+
- Full text: [`https://modernjs.dev/llms-full.txt`](https://modernjs.dev/llms-full.txt) (large — fetch on demand)
|
|
26
|
+
|
|
27
|
+
Use it when you need content beyond the bundled docs — just let your agent retrieve it on demand, no need to copy docs into your project. Typical cases: looking up another framework version, a section not included in the bundle, or getting Modern.js information outside of a project (for example before a project exists, or when researching on its own).
|
|
28
|
+
|
|
29
|
+
## Skills
|
|
30
|
+
|
|
31
|
+
Skills are on-demand AI capabilities following the [Agent Skills open standard](https://github.com/vercel-labs/skills). User-facing Skills:
|
|
32
|
+
|
|
33
|
+
| Skill | Identifier | Description |
|
|
34
|
+
| --------------- | ------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
35
|
+
| Upgrade to v3 | `modernjs-migrate-to-v3` | Migrate a v2 app to v3: safe rewrites + manual checklist + migration report |
|
|
36
|
+
| Enable features | `modernjs-feature-enable` | Enable BFF / SSG / styled-components for v3 apps, and scaffold Tailwind CSS / custom Web Server |
|
|
37
|
+
|
|
38
|
+
> Skills are not force-installed or implicitly installed — you install them explicitly. RSC and micro-frontend setups are configuration or architecture decisions, not one-click `modernjs-feature-enable` actions.
|
|
39
|
+
|
|
40
|
+
## Installing Skills
|
|
41
|
+
|
|
42
|
+
Modern.js user-facing Skills live in the repo's root `skills/` directory and follow the [Agent Skills open standard](https://github.com/vercel-labs/skills). The recommended way is the standard `skills` CLI, installing straight from GitHub:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# List installable Skills
|
|
46
|
+
npx skills add web-infra-dev/modern.js --list
|
|
47
|
+
|
|
48
|
+
# Install a single Skill into your agent directory (--agent: claude-code / codex / cursor / ...)
|
|
49
|
+
npx skills add web-infra-dev/modern.js --skill modernjs-migrate-to-v3 --agent codex -y
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
It installs the entire Skill directory (`SKILL.md` + `scripts/` + `references/`) into the corresponding agent directory, ready to trigger there.
|
|
53
|
+
|
|
54
|
+
> To pin a specific version, append `#<ref>` (a tag, branch, or commit) to the repo — it installs the Skill as of that ref (replace `<tag>` with a release tag that contains this Skill):
|
|
55
|
+
>
|
|
56
|
+
> ```bash
|
|
57
|
+
> npx skills add web-infra-dev/modern.js#<tag> --skill modernjs-migrate-to-v3 --agent codex -y
|
|
58
|
+
> ```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Glossary
|
|
2
|
+
|
|
3
|
+
## BFF
|
|
4
|
+
|
|
5
|
+
BFF is short for "Backend For Frontend". It is an architecture pattern that involves creating a backend service for frontend applications.
|
|
6
|
+
|
|
7
|
+
The BFF service acts as an intermediary between the frontend application and the server API, and can provide customized APIs for the frontend to use. This allows frontend developers to have more control over the data and functionality they need, without relying on the backend service to provide the corresponding capabilities.
|
|
8
|
+
|
|
9
|
+
## Bundler
|
|
10
|
+
|
|
11
|
+
Refers to module bundlers such as [Rspack](https://rspack.rs/).
|
|
12
|
+
|
|
13
|
+
The main goal of bundlers is to bundle JavaScript, CSS and other files together, and the bundled files can be used in the browser, Node.js or other environments. When bundler processes the Web application, it builds a dependency graph and then combines every module into one or more bundles.
|
|
14
|
+
|
|
15
|
+
## CSR
|
|
16
|
+
|
|
17
|
+
CSR stands for "Client-Side Rendering". It means that the page is rendered in the browser using JavaScript, and logic such as data fetching, templates, and routing is completed on the client side rather than the server.
|
|
18
|
+
|
|
19
|
+
In CSR, the server sends an empty HTML shell and some JavaScript scripts to the browser, and the browser fetching data from the server's API and renders dynamic content to the page.
|
|
20
|
+
|
|
21
|
+
## Module Federation
|
|
22
|
+
|
|
23
|
+
Module Federation (MF) is a technology solution that allows multiple JavaScript applications to share code and resources. Similar to microservices architecture on the server side, it allows you to split large applications into multiple independent smaller applications that can be developed, tested, and deployed independently, while dynamically loading modules from other applications at runtime.
|
|
24
|
+
|
|
25
|
+
Module Federation solves the problem of code duplication across multiple frontend applications. In the traditional approach, if multiple applications need to use the same components or utility functions, you would need to duplicate this code in each application, leading to code duplication, high maintenance costs, and larger application sizes. With Module Federation, you can place common code in one application and have other applications load it dynamically as needed, enabling code sharing and reducing duplication.
|
|
26
|
+
|
|
27
|
+
Module Federation 2.0 supports [Rspack](https://rspack.rs/) build tools, and provides enhanced features such as dynamic type hints, Manifest, Federation Runtime, runtime plugin system, and Chrome Devtools support for better development experience and debugging capabilities. You can visit the [Module Federation official documentation](https://module-federation.io/) to learn more.
|
|
28
|
+
|
|
29
|
+
Modern.js provides an example project for Module Federation. Please refer to [module-federation-examples - modernjs](https://github.com/module-federation/module-federation-examples/tree/db5bdbeee56f779999a2c591fc553eb94eb20b36/modernjs).
|
|
30
|
+
|
|
31
|
+
## Rsbuild
|
|
32
|
+
|
|
33
|
+
[Rsbuild](https://v2.rsbuild.rs/) is an Rspack-based build tool for the web. The main goal of Rsbuild is to provide out-of-the-box build capabilities for Rspack users, allowing developers to start a web project with zero configuration.
|
|
34
|
+
|
|
35
|
+
Rsbuild integrates high-performance Rust-based tools from the community, including Rspack and SWC, to provide first-class build speed and development experience.
|
|
36
|
+
|
|
37
|
+
## Rspack
|
|
38
|
+
|
|
39
|
+
[Rspack](https://rspack.rs/) is a high performance JavaScript bundler written in Rust. It offers strong compatibility with the webpack ecosystem, allowing for seamless replacement of webpack, and provides lightning fast build speeds.
|
|
40
|
+
|
|
41
|
+
Compared to webpack, Rspack has significantly improved build performance, thanks not only to the language advantages brought by Rust, but also to its parallel architecture and incremental compilation features. Benchmarking has shown that Rspack can provide 5-10 times better compilation performance.
|
|
42
|
+
|
|
43
|
+
## SSR
|
|
44
|
+
|
|
45
|
+
SSR stands for "Server-Side Rendering". It means that the HTML of the web page is generated by the server and sent to the client, rather than sending only an empty HTML shell and relying on JavaScript to generate the page content.
|
|
46
|
+
|
|
47
|
+
In traditional client-side rendering, the server sends an empty HTML shell and some JavaScript scripts to the client, and then fetching data from the server's API and fills the page with dynamic content. This leads to slow initial page loading times and is not conducive to user experience and SEO.
|
|
48
|
+
|
|
49
|
+
With SSR, the server generates HTML that already contains dynamic content and sends it to the client. This makes the initial page loading faster and more SEO-friendly, as search engines can crawl the rendered page.
|
|
50
|
+
|
|
51
|
+
## SSG
|
|
52
|
+
|
|
53
|
+
SSG stands for "Static Site Generation". It means that web pages are pre-rendered as static HTML and served directly to the client, without the need for the server to generate HTML in real-time.
|
|
54
|
+
|
|
55
|
+
In traditional SSR, the server generates HTML in real-time every time a user requests a page. With SSG, HTML can be generated in advance during the build process and hosted on a CDN or other static assets service.
|
|
56
|
+
|
|
57
|
+
Compared to traditional SSR, SSG can provide faster loading speeds and less server-side overhead, as there is no need to maintain a server to generate HTML in real-time. However, SSG is not suitable for websites that require dynamic content, as the HTML is generated during the build process and does not support real-time updates.
|
|
58
|
+
|
|
59
|
+
## SWC
|
|
60
|
+
|
|
61
|
+
[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.
|
|
62
|
+
|
|
63
|
+
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.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Introduction to Modern.js
|
|
2
|
+
|
|
3
|
+
**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.
|
|
4
|
+
|
|
5
|
+
Modern.js can provide developers with an ultimate **Development Experience** and enable applications to have better **User Experience**.
|
|
6
|
+
|
|
7
|
+
In the process of developing React applications, developers usually need to design implementation plans for certain features or use other libraries and frameworks to solve these problems. Modern.js supports all configurations and tools needed by React applications, and has built-in **additional features and optimizations**. Developers can use React to build the UI of the application, and then gradually adopt the features of Modern.js to solve common application requirements, such as routing, data acquisition, and state management.
|
|
8
|
+
|
|
9
|
+
It mainly includes the following features:
|
|
10
|
+
|
|
11
|
+
- 🚀 **Rust Bundler**: Modern.js uses Rsbuild/Rspack as the build tool, providing blazing fast compilation.
|
|
12
|
+
- 🪜 **Progressive**: Create projects with the most streamlined templates, gradually enable plugin features through the generator, and customize solutions.
|
|
13
|
+
- 🏠 **Integration**: Development and production environment web server are unique, CSR and SSR are isomorphic development, and API service calls are functions as interfaces.
|
|
14
|
+
- 🕸 **Convention Routing**: Using file-based routing helps developers quickly set up applications.
|
|
15
|
+
|
|
16
|
+
## Comparison with Others
|
|
17
|
+
|
|
18
|
+
### Next.js
|
|
19
|
+
|
|
20
|
+
Next.js is one of the most popular React frameworks in the community. It is developed by Vercel.
|
|
21
|
+
|
|
22
|
+
If you want to build a single-page application (SPA) and render it on the client side, Next.js may not be the best choice because many of its features are designed around server-first principles. If you need to use client-side rendering, you can only use limited functionality through Next.js's "static exports" feature.
|
|
23
|
+
|
|
24
|
+
Modern.js considers both client-side rendering (CSR) and server-side rendering (SSR) to be equally important. When you build a Modern.js application, it defaults to client-side rendering. You can also enable SSR or Server Components whenever you need it, and even enable SSR for specific pages. The whole process is fully progressive.
|
|
25
|
+
|
|
26
|
+
### Umi
|
|
27
|
+
|
|
28
|
+
Umi is the underlying frontend framework for the Ant Group. Modern.js and Umi share many similarities, such as support for plugin system, convention-based routing, and micro-generators.
|
|
29
|
+
|
|
30
|
+
**The main difference between Modern.js and Umi is their approach to optimizing build speed**. Umi uses MFSU technology to improve build speed, while Modern.js uses Rspack to achieve 5 to 10 times faster build speed. From our perspective, Rust tools like Rspack are more in line with the long-term evolution of the front-end toolchain, as they can strike a good balance between performance, stability, and ecosystem compatibility.
|
|
31
|
+
|
|
32
|
+
In addition, Modern.js provides richer server-side features, including comprehensive SSR capabilities, integrated BFF development capabilities, and support for custom web servers. These capabilities have been extensively validated by ByteDance in numerous online applications and can be directly used in production environments.
|
|
33
|
+
|
|
34
|
+
### Remix
|
|
35
|
+
|
|
36
|
+
Pelease refer to [Modern.js vs Remix](https://github.com/web-infra-dev/modern.js/discussions/4872).
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# Quick Start
|
|
2
|
+
|
|
3
|
+
## Environment
|
|
4
|
+
|
|
5
|
+
### Node.js
|
|
6
|
+
|
|
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.**
|
|
8
|
+
|
|
9
|
+
You can check the currently used Node.js version with the following command:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
node -v
|
|
13
|
+
```
|
|
14
|
+
|
|
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.
|
|
16
|
+
|
|
17
|
+
Here is an example of how to install the Node.js 22 LTS version via nvm:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Install the long-term support version of Node.js 22
|
|
21
|
+
nvm install 22 --lts
|
|
22
|
+
|
|
23
|
+
# Make the newly installed Node.js 22 as the default version
|
|
24
|
+
nvm alias default 22
|
|
25
|
+
|
|
26
|
+
# Switch to the newly installed Node.js 22
|
|
27
|
+
nvm use 22
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
:::tip nvm and fnm
|
|
31
|
+
Both nvm and fnm are Node.js version management tools. Relatively speaking, nvm is more mature and stable, while fnm is implemented using Rust, which provides better performance than nvm.
|
|
32
|
+
:::
|
|
33
|
+
|
|
34
|
+
Additionally, after installing nvm or fnm, when there is a `.nvmrc` file containing `lts/jod` in the repository's root directory, the system will automatically install or switch to the correct Node.js version upon entering the repository.
|
|
35
|
+
|
|
36
|
+
### pnpm
|
|
37
|
+
|
|
38
|
+
It is recommended to use [pnpm](https://pnpm.io/installation) to manage dependencies:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g pnpm@10
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
:::note
|
|
45
|
+
Modern.js also supports dependency management with `yarn` and `npm`.
|
|
46
|
+
|
|
47
|
+
:::
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
## Initialize
|
|
52
|
+
|
|
53
|
+
Modern.js provides the `@modern-js/create` tool to create projects. It does not require global installation and can be run on-demand using `npx`.
|
|
54
|
+
|
|
55
|
+
You can create a project in an existing empty directory:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
mkdir myapp && cd myapp
|
|
59
|
+
npx @modern-js/create@latest
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
You can also create a project directly in a new directory:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npx @modern-js/create@latest myapp
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`@modern-js/create` will directly create the application without providing an interactive Q & A interface:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
🚀 Welcome to Modern.js
|
|
72
|
+
|
|
73
|
+
📦 Creating project "myapp"...
|
|
74
|
+
|
|
75
|
+
✨ Project created successfully! 🎉
|
|
76
|
+
|
|
77
|
+
📋 Next, you can run the following commands:
|
|
78
|
+
|
|
79
|
+
📁 Enter the project directory:
|
|
80
|
+
|
|
81
|
+
cd myapp
|
|
82
|
+
|
|
83
|
+
🔧 Initialize Git repository:
|
|
84
|
+
|
|
85
|
+
git init
|
|
86
|
+
|
|
87
|
+
📥 Install project dependencies:
|
|
88
|
+
|
|
89
|
+
pnpm install
|
|
90
|
+
|
|
91
|
+
⚡ Start the development server:
|
|
92
|
+
|
|
93
|
+
pnpm start
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Now, the project structure is as follows:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
.
|
|
100
|
+
├── biome.json
|
|
101
|
+
├── modern.config.ts
|
|
102
|
+
├── package.json
|
|
103
|
+
├── README.md
|
|
104
|
+
├── src
|
|
105
|
+
│ ├── modern-app-env.d.ts
|
|
106
|
+
│ ├── modern.runtime.ts
|
|
107
|
+
│ └── routes
|
|
108
|
+
│ ├── index.css
|
|
109
|
+
│ ├── layout.tsx
|
|
110
|
+
│ └── page.tsx
|
|
111
|
+
└── tsconfig.json
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
Run `pnpm run dev` in the project to start the project:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
$ pnpm run dev
|
|
120
|
+
> modern dev
|
|
121
|
+
|
|
122
|
+
Modern.js Framework
|
|
123
|
+
|
|
124
|
+
ready Client compiled in 0.86 s
|
|
125
|
+
|
|
126
|
+
> Local: http://localhost:8080/
|
|
127
|
+
> Network: http://192.168.0.1:8080/
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Open `http://localhost:8080/` in your browser to see the page content.
|
|
131
|
+
|
|
132
|
+
## Configuration
|
|
133
|
+
|
|
134
|
+
In a Modern.js project created using `@modern-js/create`, a `modern.config.ts` file is generated by default.
|
|
135
|
+
|
|
136
|
+
You can modify the configuration through this file to override the default behavior of Modern.js. For example, to enable SSR, add the following configuration:
|
|
137
|
+
|
|
138
|
+
```ts title="modern.config.ts"
|
|
139
|
+
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
140
|
+
|
|
141
|
+
export default defineConfig({
|
|
142
|
+
server: {
|
|
143
|
+
ssr: true,
|
|
144
|
+
},
|
|
145
|
+
plugins: [appTools()],
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
After running `pnpm run dev` again, you can find that the project has completed page rendering on the server in the browser's Network menu.
|
|
150
|
+
|
|
151
|
+
## Core npm Package
|
|
152
|
+
|
|
153
|
+
In a newly created project, the `@modern-js/app-tools` npm package is installed by default. It is the core package of the Modern.js framework and provides the following capabilities:
|
|
154
|
+
|
|
155
|
+
- It offers commonly used CLI commands such as `modern dev`, `modern build`, and more.
|
|
156
|
+
- It integrates Rsbuild, providing build capabilities.
|
|
157
|
+
- It integrates Modern.js Server, providing capabilities for development and production servers.
|
|
158
|
+
|
|
159
|
+
`@modern-js/app-tools` is implemented based on the plugin system of Modern.js. Essentially, it is a plugin. Therefore, you need to register `appTools` in the `plugins` field of the configuration file:
|
|
160
|
+
|
|
161
|
+
```ts title="modern.config.ts"
|
|
162
|
+
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
163
|
+
|
|
164
|
+
export default defineConfig({
|
|
165
|
+
plugins: [appTools()],
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Build the project
|
|
170
|
+
|
|
171
|
+
To build the production artifacts of the project, run `pnpm run build` in the project:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
$ pnpm run build
|
|
175
|
+
|
|
176
|
+
> modern build
|
|
177
|
+
|
|
178
|
+
Modern.js Framework
|
|
179
|
+
|
|
180
|
+
info Starting production build...
|
|
181
|
+
info Type checker is enabled. It may take some time.
|
|
182
|
+
ready Client compiled in 6.19 s
|
|
183
|
+
info Production file sizes:
|
|
184
|
+
|
|
185
|
+
File Size Gzipped
|
|
186
|
+
dist/routes-manifest.json 0.74 kB 0.28 kB
|
|
187
|
+
dist/static/css/async/page.d7915515.css 1.4 kB 0.69 kB
|
|
188
|
+
dist/static/js/main.5ae469e7.js 3.0 kB 1.3 kB
|
|
189
|
+
dist/html/index/index.html 6.0 kB 2.6 kB
|
|
190
|
+
dist/static/js/async/page.ddc8a4c1.js 19.2 kB 6.7 kB
|
|
191
|
+
dist/static/js/34.171fffdb.js 21.3 kB 7.1 kB
|
|
192
|
+
dist/static/js/lib-router.8995a55e.js 55.3 kB 18.1 kB
|
|
193
|
+
dist/static/js/lib-lodash.53ec3384.js 71.4 kB 24.8 kB
|
|
194
|
+
dist/static/js/lib-react.b5856db9.js 140.0 kB 45.2 kB
|
|
195
|
+
dist/static/js/lib-polyfill.86c452b3.js 213.3 kB 69.9 kB
|
|
196
|
+
|
|
197
|
+
Total size: 531.8 kB
|
|
198
|
+
Gzipped size: 176.7 kB
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
By default, the build artifacts are generated in `dist/`, with the following directory structure:
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
dist
|
|
205
|
+
├── html
|
|
206
|
+
│ └── index
|
|
207
|
+
├── modern.config.json
|
|
208
|
+
├── route.json
|
|
209
|
+
├── routes-manifest.json
|
|
210
|
+
└── static
|
|
211
|
+
├── css
|
|
212
|
+
└── js
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
> If you need to customize the directory of the build artifacts, please refer to [Output files](/guides/basic-features/output-files.md).
|
|
216
|
+
|
|
217
|
+
## Verify
|
|
218
|
+
|
|
219
|
+
Run `pnpm run serve` in the project to verify whether the build artifacts run normally locally:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
$ pnpm run serve
|
|
223
|
+
|
|
224
|
+
Modern.js Framework
|
|
225
|
+
|
|
226
|
+
info Starting production server...
|
|
227
|
+
|
|
228
|
+
> Local: http://localhost:8080/
|
|
229
|
+
> Network: http://192.168.0.1:8080/
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Open `http://localhost:8080/` in the browser, and the content should be consistent with that of `pnpm run dev`.
|
|
233
|
+
|
|
234
|
+
## Deployment
|
|
235
|
+
|
|
236
|
+
After local develop, you can refer to the [Deployment](/guides/basic-features/deploy.md) section to deploy the project to the server.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Tech Stack
|
|
2
|
+
|
|
3
|
+
The Modern.js framework comes with built-in popular libraries and development tools from the community.
|
|
4
|
+
|
|
5
|
+
In this document, you can learn about the main technology stack involved in the Modern.js framework, as well as some optional libraries and tools.
|
|
6
|
+
|
|
7
|
+
## UI Library
|
|
8
|
+
|
|
9
|
+
Modern.js uses [React 19](https://react.dev/) to build user interfaces and is also compatible with React 18.
|
|
10
|
+
|
|
11
|
+
Rsbuild supports building Vue applications. If you need to use Vue, you can refer to ["Rsbuild - Vue"](https://v2.rsbuild.rs/guide/framework/vue).
|
|
12
|
+
|
|
13
|
+
## Routing
|
|
14
|
+
|
|
15
|
+
Modern.js uses [React Router v7](https://reactrouter.com/en/main) for routing.
|
|
16
|
+
|
|
17
|
+
Modern.js supports conventional routing, self-controlled routing, or other routing schemes. Please refer to ["Routing"](/guides/basic-features/routes/routes.md) to make your choice.
|
|
18
|
+
|
|
19
|
+
## Package Manager
|
|
20
|
+
|
|
21
|
+
Modern.js can be used with any community package manager, such as [npm](https://www.npmjs.com/package/npm), [yarn](https://classic.yarnpkg.com/lang/en/), [pnpm](https://pnpm.io/), or [Bun](https://bun.sh/).
|
|
22
|
+
|
|
23
|
+
We recommend using pnpm for faster installation speed.
|
|
24
|
+
|
|
25
|
+
## Bundler
|
|
26
|
+
|
|
27
|
+
Modern.js uses [Rspack](https://rspack.rs/) to bundle your web applications.
|
|
28
|
+
|
|
29
|
+
## Transpiler
|
|
30
|
+
|
|
31
|
+
Modern.js uses [SWC](https://swc.rs/) as JavaScript transpiler to transform TypeScript or JSX into JavaScript code that can run in browsers and perform syntax downgrades.
|
|
32
|
+
|
|
33
|
+
When using Rspack for building, `babel-loader` is not enabled by default. If you need to add [Babel](https://babeljs.io/) plugins, you can configure them through [`babel plugin`](https://v2.rsbuild.rs/plugins/list/plugin-babel#babel-plugin), which will generate additional compilation overhead and slow down Rspack build speed to some extent.
|
|
34
|
+
|
|
35
|
+
## Minimizer
|
|
36
|
+
|
|
37
|
+
During production builds, Modern.js uses [SWC](https://swc.rs/) to minify JS code.
|
|
38
|
+
|
|
39
|
+
## CSS Transformer
|
|
40
|
+
|
|
41
|
+
Modern.js uses [PostCSS](https://postcss.org/) to transform CSS code and enables [autoprefixer](https://github.com/postcss/autoprefixer) by default to add CSS prefixes.
|
|
42
|
+
|
|
43
|
+
Modern.js supports enabling ["Lightning CSS"](/configure/app/tools/lightningcss-loader.md), which uses Lightning CSS to downgrade CSS syntax.
|
|
44
|
+
|
|
45
|
+
Modern.js supports enabling ["Tailwind CSS"](/guides/basic-features/css/tailwindcss.md) and is compatible with both Tailwind CSS v3 and v4.
|
|
46
|
+
|
|
47
|
+
## CSS Preprocessors
|
|
48
|
+
|
|
49
|
+
Modern.js supports three CSS preprocessors: [Sass](https://sass-lang.com/), [Less](https://lesscss.org/), and [Stylus](https://stylus-lang.com/):
|
|
50
|
+
|
|
51
|
+
- Sass and Less are supported by default and ready to use.
|
|
52
|
+
- Stylus is optional and can be used by referring to the ["Stylus Plugin"](https://v2.rsbuild.rs/plugins/list/plugin-stylus).
|
|
53
|
+
|
|
54
|
+
## CSS Modules
|
|
55
|
+
|
|
56
|
+
Modern.js provides out-of-the-box support for [CSS Modules](https://github.com/css-modules/css-modules), which is implemented internally based on [css-loader](https://www.npmjs.com/package/css-loader).
|
|
57
|
+
|
|
58
|
+
Please refer to ["Use CSS Modules"](/guides/basic-features/css/css-modules.md) for usage instructions.
|
|
59
|
+
|
|
60
|
+
## CSS-in-JS
|
|
61
|
+
|
|
62
|
+
Modern.js supports the use of [styled-components](https://styled-components.com/). Please refer to ["Using CSS-in-JS"](/guides/basic-features/css/css-in-js.md) for usage instructions.
|
|
63
|
+
|
|
64
|
+
If you need to use other CSS-in-JS solutions, you can integrate them into your project on your own.
|
|
65
|
+
|
|
66
|
+
## UI Components
|
|
67
|
+
|
|
68
|
+
Modern.js can be used with any React UI component library from the community, such as [MUI](https://mui.com/), [Ant Design](https://ant.design/), [Arco Design](https://github.com/arco-design/arco-design), [Semi Design](https://semi.design/), [Radix UI](https://www.radix-ui.com/), and more.
|
|
69
|
+
|
|
70
|
+
## Component Development
|
|
71
|
+
|
|
72
|
+
Modern.js supports the use of [Storybook](https://storybook.js.org/) for developing UI components. This feature is optional. Please refer to ["Using Storybook"](/guides/basic-features/debug/using-storybook.md) to enable it.
|
|
73
|
+
|
|
74
|
+
## Testing Framework
|
|
75
|
+
|
|
76
|
+
Modern.js recommends [Rstest](https://rstest.rs/) for unit tests and component tests. Rstest is built on Rspack for fast startup and execution, and it can reuse your Modern.js app configuration through [`@modern-js/adapter-rstest`](/guides/basic-features/testing/rstest.md).
|
|
77
|
+
|
|
78
|
+
For end-to-end (E2E) tests, you can use [Playwright](/guides/basic-features/testing/playwright.md).
|
|
79
|
+
|
|
80
|
+
## Node.js Framework
|
|
81
|
+
|
|
82
|
+
Modern.js Server and BFF use [Hono.js](https://hono.dev/) as the runtime framework, and you can extend the Server based on the Hono.js ecosystem. Please refer to [Custom Web Server](/guides/advanced-features/web-server.md).
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Upgrading
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
## Manual Upgrade
|
|
5
|
+
|
|
6
|
+
All Modern.js official packages are released with a **uniform version number**, so when upgrading, you need to update all `@modern-js/**` packages to the target version uniformly.
|
|
7
|
+
|
|
8
|
+
### Upgrade Steps
|
|
9
|
+
|
|
10
|
+
1. **Check the latest version**
|
|
11
|
+
|
|
12
|
+
You can check the latest version of Modern.js through the following methods:
|
|
13
|
+
|
|
14
|
+
- Visit [npm](https://www.npmjs.com/package/@modern-js/app-tools) to check the latest version of `@modern-js/app-tools`
|
|
15
|
+
- Check [GitHub Releases](https://github.com/web-infra-dev/modern.js/releases)
|
|
16
|
+
|
|
17
|
+
According to the [Release Note](https://github.com/web-infra-dev/modern.js/releases) on the official website, developers can also manually upgrade the project to the desired version.
|
|
18
|
+
|
|
19
|
+
2. **Update package.json**
|
|
20
|
+
|
|
21
|
+
In the project's `package.json`, update all `@modern-js/**` packages to the target version. For example:
|
|
22
|
+
|
|
23
|
+
```json title="package.json"
|
|
24
|
+
{
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@modern-js/app-tools": "3.0.0",
|
|
27
|
+
"@modern-js/runtime": "3.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@modern-js/types": "3.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
3. **Reinstall dependencies**
|
|
36
|
+
|
|
37
|
+
After updating `package.json`, reinstall dependencies:
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
```sh [npm]
|
|
41
|
+
npm install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```sh [yarn]
|
|
45
|
+
yarn install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```sh [pnpm]
|
|
49
|
+
pnpm install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```sh [bun]
|
|
53
|
+
bun install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```sh [deno]
|
|
57
|
+
deno install
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
:::tip
|
|
61
|
+
When upgrading, you need to upgrade all packages provided by Modern.js uniformly, rather than upgrading individual dependencies. Ensure that all `@modern-js/**` packages have the same version number.
|
|
62
|
+
:::
|
|
63
|
+
|
|
64
|
+
## Version Management Strategy
|
|
65
|
+
|
|
66
|
+
In Modern.js projects, we recommend that all officially provided dependencies use fixed version, and avoid using `^` or `~` for range declarations. For example:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"@modern-js/app-tools": "x.y.z"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This ensures that the versions of dependencies are fully determined, thereby guaranteeing build consistency and predictability.
|
|
77
|
+
|
|
78
|
+
## Lock nested dependency
|
|
79
|
+
|
|
80
|
+
When a nested dependency of the project has a problem and Modern.js cannot be updated immediately, you can use the package manager to lock the version of the nested dependency.
|
|
81
|
+
|
|
82
|
+
### pnpm
|
|
83
|
+
|
|
84
|
+
For projects using pnpm, add the following configuration to the `package.json` in the **root directory** of the project, and then run `pnpm install` again:
|
|
85
|
+
|
|
86
|
+
```json title="package.json"
|
|
87
|
+
{
|
|
88
|
+
"pnpm": {
|
|
89
|
+
"overrides": {
|
|
90
|
+
"package-name": "^1.0.0"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Yarn
|
|
97
|
+
|
|
98
|
+
For projects using Yarn, add the following configuration to the `package.json` in the **root directory** of the project, and then run `yarn install` again:
|
|
99
|
+
|
|
100
|
+
```json title="package.json"
|
|
101
|
+
{
|
|
102
|
+
"resolutions": {
|
|
103
|
+
"package-name": "^1.0.0"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Npm
|
|
109
|
+
|
|
110
|
+
For projects using Npm, add the following configuration to the `package.json` in the **root directory** of the project, and then run `npm install` again:
|
|
111
|
+
|
|
112
|
+
```json title="package.json"
|
|
113
|
+
{
|
|
114
|
+
"overrides": {
|
|
115
|
+
"package-name": "^1.0.0"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
:::info
|
|
121
|
+
For Monorepo repositories, you can only lock dependency versions in the `package.json` in the root directory of the project, and it will affect all packages in the Monorepo.
|
|
122
|
+
|
|
123
|
+
:::
|