@modern-js/main-doc 2.4.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/LICENSE +0 -123
- package/README.md +26 -0
- package/en/apis/app/commands.mdx +297 -0
- package/en/apis/app/hooks/_category_.json +2 -5
- package/en/apis/app/hooks/api/framework/lambda.mdx +1 -1
- package/en/apis/app/hooks/api/functions/api.mdx +1 -1
- package/en/apis/app/hooks/server/index_.mdx +2 -1
- package/en/apis/app/hooks/src/pages.mdx +7 -7
- package/en/apis/app/hooks/src/routes.mdx +3 -3
- package/en/apis/app/runtime/_category_.json +1 -5
- package/en/apis/app/runtime/app/define-config.mdx +2 -2
- package/en/apis/app/runtime/core/bootstrap.mdx +1 -1
- package/en/apis/app/runtime/core/create-app.mdx +2 -2
- package/en/apis/app/runtime/core/use-loader.mdx +4 -4
- package/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
- package/en/apis/app/runtime/model/Provider.mdx +2 -2
- package/en/apis/app/runtime/model/auto-actions.mdx +2 -2
- package/en/apis/app/runtime/model/connect.mdx +5 -5
- package/en/apis/app/runtime/model/create-app.mdx +9 -9
- package/en/apis/app/runtime/model/create-store.mdx +3 -3
- package/en/apis/app/runtime/model/handle-effect.mdx +2 -2
- package/en/apis/app/runtime/model/model_.mdx +1 -1
- package/en/apis/app/runtime/model/use-local-model.mdx +1 -1
- package/en/apis/app/runtime/model/use-model.mdx +1 -1
- package/en/apis/app/runtime/model/use-static-model.mdx +4 -4
- package/en/apis/app/runtime/model/use-store.mdx +1 -1
- package/en/apis/app/runtime/router/router.mdx +1 -1
- package/en/apis/app/runtime/ssr/pre-render.mdx +1 -1
- package/en/apis/app/runtime/testing/render.mdx +1 -1
- package/en/apis/app/runtime/testing/renderApp.mdx +1 -1
- package/en/apis/app/runtime/utility/css-in-js.mdx +1 -1
- package/en/apis/app/runtime/utility/loadable.mdx +1 -1
- package/en/apis/app/runtime/web-server/hook.mdx +5 -5
- package/en/apis/app/runtime/web-server/middleware.mdx +6 -6
- package/en/components/global-proxy-config.mdx +3 -3
- package/en/components/init-app.mdx +5 -5
- package/en/configure/app/bff/_category_.json +4 -0
- package/en/configure/app/bff/prefix.mdx +2 -3
- package/en/configure/app/bff/proxy.mdx +1 -1
- package/en/configure/app/builder-plugins.mdx +3 -3
- package/en/configure/app/deploy/_category_.json +4 -0
- package/en/configure/app/dev/_category_.json +4 -0
- package/en/configure/app/dev/asset-prefix.mdx +1 -1
- package/en/configure/app/dev/before-start-url.mdx +13 -0
- package/en/configure/app/dev/hmr.mdx +1 -1
- package/en/configure/app/dev/host.mdx +13 -0
- package/en/configure/app/dev/https.mdx +1 -1
- package/en/configure/app/dev/port.mdx +1 -1
- package/en/configure/app/dev/progress-bar.mdx +1 -1
- package/en/configure/app/dev/start-url.mdx +1 -1
- package/en/configure/app/experiments/_category_.json +4 -0
- package/en/configure/app/experiments/lazy-compilation.mdx +1 -1
- package/en/configure/app/html/_category_.json +4 -0
- package/en/configure/app/html/app-icon.mdx +1 -1
- package/en/configure/app/html/crossorigin.mdx +1 -1
- package/en/configure/app/html/disable-html-folder.mdx +1 -1
- package/en/configure/app/html/favicon-by-entries.mdx +1 -1
- package/en/configure/app/html/favicon.mdx +1 -1
- package/en/configure/app/html/inject-by-entries.mdx +1 -1
- package/en/configure/app/html/inject.mdx +1 -1
- package/en/configure/app/html/meta-by-entries.mdx +1 -1
- package/en/configure/app/html/meta.mdx +1 -1
- package/en/configure/app/html/mount-id.mdx +1 -1
- package/en/configure/app/html/tags-by-entries.mdx +1 -1
- package/en/configure/app/html/tags.mdx +1 -1
- package/en/configure/app/html/template-by-entries.mdx +1 -1
- package/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
- package/en/configure/app/html/template-parameters.mdx +1 -1
- package/en/configure/app/html/template.mdx +1 -1
- package/en/configure/app/html/title-by-entries.mdx +1 -1
- package/en/configure/app/html/title.mdx +1 -1
- package/en/configure/app/output/_category_.json +4 -0
- package/en/configure/app/output/asset-prefix.mdx +1 -1
- package/en/configure/app/output/assets-retry.mdx +1 -1
- package/en/configure/app/output/charset.mdx +1 -1
- package/en/configure/app/output/clean-dist-path.mdx +1 -1
- package/en/configure/app/output/convert-to-rem.mdx +1 -1
- package/en/configure/app/output/copy.mdx +1 -1
- package/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
- package/en/configure/app/output/data-uri-limit.mdx +1 -1
- package/en/configure/app/output/disable-css-extract.mdx +1 -1
- package/en/configure/app/output/disable-css-module-extension.mdx +1 -1
- package/en/configure/app/output/disable-filename-hash.mdx +1 -1
- package/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
- package/en/configure/app/output/disable-minimize.mdx +1 -1
- package/en/configure/app/output/disable-source-map.mdx +1 -1
- package/en/configure/app/output/disable-ts-checker.mdx +1 -1
- package/en/configure/app/output/dist-path.mdx +1 -1
- package/en/configure/app/output/enable-asset-fallback.mdx +1 -1
- package/en/configure/app/output/enable-asset-manifest.mdx +1 -1
- package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
- package/en/configure/app/output/enable-inline-scripts.mdx +1 -1
- package/en/configure/app/output/enable-inline-styles.mdx +1 -1
- package/en/configure/app/output/enable-latest-decorators.mdx +1 -1
- package/en/configure/app/output/externals.mdx +1 -1
- package/en/configure/app/output/filename.mdx +1 -1
- package/en/configure/app/output/legal-comments.mdx +1 -1
- package/en/configure/app/output/override-browserslist.mdx +1 -1
- package/en/configure/app/output/polyfill.mdx +1 -1
- package/en/configure/app/output/ssg.mdx +5 -5
- package/en/configure/app/output/svg-default-export.mdx +1 -1
- package/en/configure/app/performance/_category_.json +4 -0
- package/en/configure/app/performance/build-cache.mdx +1 -1
- package/en/configure/app/performance/bundle-analyze.mdx +1 -1
- package/en/configure/app/performance/chunk-split.mdx +1 -1
- package/en/configure/app/performance/print-file-size.mdx +1 -1
- package/en/configure/app/performance/profile.mdx +1 -1
- package/en/configure/app/performance/remove-console.mdx +1 -1
- package/en/configure/app/performance/remove-moment-locale.mdx +1 -1
- package/en/configure/app/plugins.mdx +1 -1
- package/en/configure/app/runtime/_category_.json +4 -0
- package/en/configure/app/runtime/intro.mdx +2 -2
- package/en/configure/app/runtime/master-app.mdx +1 -1
- package/en/configure/app/security/_category_.json +4 -0
- package/en/configure/app/security/check-syntax.mdx +1 -1
- package/en/configure/app/security/sri.mdx +1 -1
- package/en/configure/app/server/_category_.json +4 -0
- package/en/configure/app/server/base-url.mdx +3 -3
- package/en/configure/app/server/enable-framework-ext.mdx +1 -1
- package/en/configure/app/server/ssr-by-entries.mdx +1 -1
- package/en/configure/app/source/_category_.json +4 -0
- package/en/configure/app/source/alias.mdx +1 -1
- package/en/configure/app/source/compile-js-data-uri.mdx +1 -1
- package/en/configure/app/source/define.mdx +1 -1
- package/en/configure/app/source/design-system.mdx +5 -5
- package/en/configure/app/source/entries-dir.mdx +1 -1
- package/en/configure/app/source/entries.mdx +3 -3
- package/en/configure/app/source/exclude.mdx +1 -1
- package/en/configure/app/source/global-vars.mdx +1 -1
- package/en/configure/app/source/include.mdx +1 -1
- package/en/configure/app/source/module-scopes.mdx +1 -1
- package/en/configure/app/source/pre-entry.mdx +1 -1
- package/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
- package/en/configure/app/source/resolve-main-fields.mdx +1 -1
- package/en/configure/app/testing/_category_.json +4 -0
- package/en/configure/app/testing/transformer.mdx +1 -1
- package/en/configure/app/tools/_category_.json +4 -0
- package/en/configure/app/tools/autoprefixer.mdx +1 -1
- package/en/configure/app/tools/babel.mdx +1 -1
- package/en/configure/app/tools/css-extract.mdx +1 -1
- package/en/configure/app/tools/css-loader.mdx +1 -1
- package/en/configure/app/tools/dev-server.mdx +1 -1
- package/en/configure/app/tools/html-plugin.mdx +1 -1
- package/en/configure/app/tools/inspector.mdx +1 -1
- package/en/configure/app/tools/jest.mdx +1 -1
- package/en/configure/app/tools/less.mdx +1 -1
- package/en/configure/app/tools/minify-css.mdx +1 -1
- package/en/configure/app/tools/postcss.mdx +1 -1
- package/en/configure/app/tools/pug.mdx +1 -1
- package/en/configure/app/tools/rspack.mdx +13 -0
- package/en/configure/app/tools/sass.mdx +1 -1
- package/en/configure/app/tools/style-loader.mdx +1 -1
- package/en/configure/app/tools/styled-components.mdx +1 -1
- package/en/configure/app/tools/tailwindcss.mdx +1 -1
- package/en/configure/app/tools/terser.mdx +1 -1
- package/en/configure/app/tools/ts-checker.mdx +1 -1
- package/en/configure/app/tools/ts-loader.mdx +1 -1
- package/en/configure/app/tools/webpack-chain.mdx +1 -1
- package/en/configure/app/tools/webpack.mdx +1 -1
- package/en/configure/app/usage.mdx +1 -1
- package/en/guides/advanced-features/_category_.json +2 -2
- package/en/guides/advanced-features/bff/bff-proxy.mdx +1 -1
- package/en/guides/advanced-features/bff/frameworks.mdx +1 -1
- package/en/guides/advanced-features/bff/function.mdx +3 -3
- package/en/guides/advanced-features/code-split.mdx +2 -2
- package/en/guides/advanced-features/compatibility.mdx +2 -3
- package/en/guides/advanced-features/eslint.mdx +4 -4
- package/en/guides/advanced-features/low-level.mdx +1 -1
- package/en/guides/advanced-features/rspack-start.mdx +69 -0
- package/en/guides/advanced-features/ssg.mdx +12 -13
- package/en/guides/advanced-features/ssr.mdx +3 -3
- package/en/guides/advanced-features/testing.mdx +4 -5
- package/en/guides/advanced-features/web-server.mdx +0 -1
- package/en/guides/basic-features/alias.mdx +5 -5
- package/en/guides/basic-features/data-fetch.mdx +25 -12
- package/en/guides/basic-features/env-vars.mdx +1 -1
- package/en/guides/basic-features/html.mdx +11 -11
- package/en/guides/basic-features/mock.mdx +21 -1
- package/en/guides/basic-features/proxy.mdx +2 -2
- package/en/guides/basic-features/routes.mdx +29 -15
- package/en/guides/{basic-features → concept}/builder.mdx +2 -2
- package/en/guides/concept/entries.mdx +11 -11
- package/en/guides/css/_category_.json +5 -0
- package/en/guides/{basic-features/css → css}/less-sass.mdx +1 -1
- package/en/guides/get-started/introduction.mdx +34 -0
- package/en/guides/get-started/quick-start.mdx +4 -4
- package/en/guides/get-started/upgrade.mdx +2 -1
- package/en/guides/topic-detail/_category_.json +2 -2
- package/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +1 -1
- package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
- package/en/guides/topic-detail/micro-frontend/c02-development.mdx +128 -61
- package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +73 -42
- package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
- package/en/guides/topic-detail/model/auto-actions.mdx +1 -1
- package/en/guides/topic-detail/model/define-model.mdx +1 -1
- package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
- package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/en/guides/topic-detail/model/quick-start.mdx +2 -2
- package/en/guides/topic-detail/model/test-model.mdx +1 -1
- package/en/guides/topic-detail/model/use-model.mdx +3 -3
- package/en/guides/troubleshooting/_category_.json +2 -2
- package/en/guides/troubleshooting/cli.mdx +1 -1
- package/en/index.md +1 -1
- package/en/tutorials/first-app/_category_.json +1 -1
- package/en/tutorials/first-app/c01-start.mdx +0 -1
- package/en/tutorials/first-app/c03-css.mdx +1 -2
- package/en/tutorials/first-app/c06-model.mdx +1 -1
- package/en/tutorials/first-app/c07-container.mdx +18 -18
- package/en/tutorials/first-app/c08-entries.mdx +24 -25
- package/en/tutorials/foundations/introduction.mdx +17 -34
- package/package.json +3 -3
- package/scripts/config.ts +3 -1
- package/scripts/summary.en.json +1 -1
- package/scripts/summary.zh.json +1 -1
- package/zh/apis/app/commands.mdx +299 -0
- package/zh/apis/app/hooks/_category_.json +2 -5
- package/zh/apis/app/hooks/src/pages.mdx +1 -1
- package/zh/apis/app/hooks/src/routes.mdx +3 -3
- package/zh/apis/app/runtime/_category_.json +1 -5
- package/zh/apis/app/runtime/core/create-app.mdx +1 -1
- package/zh/apis/app/runtime/core/use-module-apps.mdx +81 -40
- package/zh/apis/app/runtime/model/Provider.mdx +2 -2
- package/zh/apis/app/runtime/model/create-app.mdx +7 -7
- package/zh/apis/app/runtime/model/create-store.mdx +2 -2
- package/zh/apis/app/runtime/model/use-local-model.mdx +1 -1
- package/zh/apis/app/runtime/model/use-static-model.mdx +1 -1
- package/zh/apis/app/runtime/model/use-store.mdx +1 -1
- package/zh/apis/app/runtime/testing/renderApp.mdx +1 -1
- package/zh/components/init-app.mdx +5 -5
- package/zh/components/micro-runtime-config.mdx +6 -6
- package/zh/components/release-note.mdx +1 -1
- package/zh/configure/app/bff/prefix.mdx +1 -1
- package/zh/configure/app/bff/proxy.mdx +1 -1
- package/zh/configure/app/builder-plugins.mdx +3 -3
- package/zh/configure/app/dev/before-start-url.mdx +13 -0
- package/zh/configure/app/dev/host.mdx +13 -0
- package/zh/configure/app/output/ssg.mdx +3 -3
- package/zh/configure/app/plugins.mdx +1 -1
- package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
- package/zh/configure/app/source/entries-dir.mdx +1 -1
- package/zh/configure/app/tools/rspack.mdx +13 -0
- package/zh/configure/app/usage.mdx +1 -1
- package/zh/guides/advanced-features/_category_.json +2 -6
- package/zh/guides/advanced-features/compatibility.mdx +0 -1
- package/zh/guides/advanced-features/rspack-start.mdx +69 -0
- package/zh/guides/advanced-features/ssg.mdx +8 -9
- package/zh/guides/advanced-features/ssr.mdx +3 -2
- package/zh/guides/advanced-features/testing.mdx +0 -1
- package/zh/guides/advanced-features/web-server.mdx +0 -1
- package/zh/guides/basic-features/_category_.json +1 -5
- package/zh/guides/basic-features/alias.mdx +5 -5
- package/zh/guides/basic-features/data-fetch.mdx +39 -30
- package/zh/guides/basic-features/html.mdx +10 -9
- package/zh/guides/basic-features/mock.mdx +20 -0
- package/zh/guides/basic-features/routes.mdx +38 -17
- package/zh/guides/{basic-features → concept}/builder.mdx +4 -4
- package/zh/guides/concept/entries.mdx +11 -11
- package/zh/guides/css/_category_.json +5 -0
- package/zh/guides/{basic-features/css → css}/less-sass.mdx +1 -1
- package/zh/guides/{basic-features/css → css}/postcss.mdx +5 -4
- package/zh/guides/{basic-features/css → css}/tailwindcss.mdx +0 -1
- package/zh/guides/get-started/introduction.mdx +31 -0
- package/zh/guides/get-started/quick-start.mdx +4 -5
- package/zh/guides/get-started/upgrade.mdx +2 -1
- package/zh/guides/topic-detail/_category_.json +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
- package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +25 -0
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +16 -16
- package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
- package/zh/guides/troubleshooting/_category_.json +2 -2
- package/zh/index.md +1 -1
- package/zh/tutorials/first-app/_category_.json +1 -1
- package/zh/tutorials/first-app/c01-start.mdx +1 -2
- package/zh/tutorials/first-app/c03-css.mdx +1 -2
- package/zh/tutorials/first-app/c06-model.mdx +2 -2
- package/zh/tutorials/first-app/c07-container.mdx +18 -18
- package/zh/tutorials/first-app/c08-entries.mdx +25 -26
- package/zh/tutorials/foundations/introduction.mdx +14 -29
- package/en/apis/app/commands/_category_.json +0 -8
- package/en/apis/app/commands/build.mdx +0 -39
- package/en/apis/app/commands/dev.mdx +0 -61
- package/en/apis/app/commands/index.mdx +0 -7
- package/en/apis/app/commands/inspect.mdx +0 -61
- package/en/apis/app/commands/lint.mdx +0 -19
- package/en/apis/app/commands/new.mdx +0 -54
- package/en/apis/app/commands/serve.mdx +0 -27
- package/en/apis/app/commands/test.mdx +0 -35
- package/en/apis/app/commands/upgrade.mdx +0 -18
- package/en/apis/app/hooks/index.mdx +0 -7
- package/en/apis/app/runtime/index.mdx +0 -7
- package/en/guides/advanced-features/index.mdx +0 -7
- package/en/guides/basic-features/css/_category_.json +0 -4
- package/zh/apis/app/commands/_category_.json +0 -8
- package/zh/apis/app/commands/build.mdx +0 -39
- package/zh/apis/app/commands/dev.mdx +0 -61
- package/zh/apis/app/commands/index.mdx +0 -7
- package/zh/apis/app/commands/inspect.mdx +0 -61
- package/zh/apis/app/commands/lint.mdx +0 -19
- package/zh/apis/app/commands/new.mdx +0 -54
- package/zh/apis/app/commands/serve.mdx +0 -27
- package/zh/apis/app/commands/test.mdx +0 -35
- package/zh/apis/app/commands/upgrade.mdx +0 -18
- package/zh/apis/app/hooks/index.mdx +0 -7
- package/zh/apis/app/runtime/index.mdx +0 -7
- package/zh/guides/advanced-features/index.mdx +0 -7
- package/zh/guides/basic-features/css/_category_.json +0 -4
- package/zh/guides/basic-features/index.mdx +0 -7
- /package/en/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
- /package/en/guides/{basic-features/css → css}/css-modules.mdx +0 -0
- /package/en/guides/{basic-features/css → css}/postcss.mdx +0 -0
- /package/en/guides/{basic-features/css → css}/tailwindcss.mdx +0 -0
- /package/zh/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
- /package/zh/guides/{basic-features/css → css}/css-modules.mdx +0 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
---
|
2
|
+
title: Rspack Start
|
3
|
+
sidebar_position: 12
|
4
|
+
---
|
5
|
+
|
6
|
+
# Rspack Start
|
7
|
+
|
8
|
+
[Rspack](https://www.rspack.org/) is a Rust-based web bundler developed by the ByteDance Web Infra team. The core architecture of Rspack is aligned with the implementation of webpack, and provides out-of-the-box support for commonly used build features.
|
9
|
+
|
10
|
+
Rspack optimizes compilation performance by:
|
11
|
+
|
12
|
+
- Highly LTO optimized Native code.
|
13
|
+
- Take full advantage of multi-core, and the entire compilation process is fully optimized for multi-threading.
|
14
|
+
- On-demand compilation based on request (Lazy Compilation), reducing the number of modules per compilation to improve the speed of cold start.
|
15
|
+
|
16
|
+
## Initializing an rspack project
|
17
|
+
|
18
|
+
The Modern.js generator provides an interactive question-and-answer interface to initialize a project. To create an rspack project, simply select the **rspack** build tool by running:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
$ npx @modern-js/create myapp
|
22
|
+
? Please select the solution you want to create: Web App Solution
|
23
|
+
? Development Language: TS
|
24
|
+
? Package Management Tool: pnpm
|
25
|
+
? Build Tools: rspack
|
26
|
+
```
|
27
|
+
|
28
|
+
After the project is created, you can experience the project by running `pnpm run dev`. For more project information, please refer to [Quick Start](/guides/get-started/quick-start.html).
|
29
|
+
|
30
|
+
:::tip
|
31
|
+
When using rspack as the bundler, the following features are currently not supported:
|
32
|
+
|
33
|
+
- Server-side rendering (SSR)
|
34
|
+
- Static Site Generation (SSG)
|
35
|
+
- Micro Frontend.
|
36
|
+
- Storybook debugging.
|
37
|
+
|
38
|
+
:::
|
39
|
+
|
40
|
+
## Migrating from webpack to rspack
|
41
|
+
|
42
|
+
You can enable rspack build by running `pnpm run new`:
|
43
|
+
|
44
|
+
```bash
|
45
|
+
$ pnpm run new
|
46
|
+
? Action: Enable features
|
47
|
+
? Enable features: Enable rspack Build
|
48
|
+
```
|
49
|
+
|
50
|
+
After executing the command, enable the rspack build in `modern.config.ts`:
|
51
|
+
|
52
|
+
```ts title=modern.config.ts
|
53
|
+
import appTools, { defineConfig } from '@modern-js/app-tools';
|
54
|
+
|
55
|
+
export default defineConfig<'rspack'>({
|
56
|
+
runtime: {
|
57
|
+
router: true,
|
58
|
+
},
|
59
|
+
plugins: [
|
60
|
+
appTools({
|
61
|
+
bundler: 'experimental-rspack',
|
62
|
+
}),
|
63
|
+
],
|
64
|
+
});
|
65
|
+
```
|
66
|
+
|
67
|
+
:::tip
|
68
|
+
Migrating from webpack to rspack may have some differences in build and configuration capabilities. For more details, please refer to [Configuration Differences](https://modernjs.dev/builder/en/guide/advanced/rspack-start.html#migrating-from-webpack-to-rspack)
|
69
|
+
:::
|
@@ -9,8 +9,8 @@ Static Site Generation is a solution for rendering complete static web pages at
|
|
9
9
|
First need to execute `pnpm run new` to enable the SSG features:
|
10
10
|
|
11
11
|
```bash
|
12
|
-
?
|
13
|
-
?
|
12
|
+
? Action Enable features
|
13
|
+
? Enable features Enable SSG
|
14
14
|
```
|
15
15
|
|
16
16
|
After execute script,register SSG plugin in `modern.config.ts`:
|
@@ -18,7 +18,6 @@ After execute script,register SSG plugin in `modern.config.ts`:
|
|
18
18
|
```ts title="modern.config.ts"
|
19
19
|
import ssgPlugin from '@modern-js/plugin-ssg';
|
20
20
|
|
21
|
-
// https://modernjs.dev/docs/apis/app/config
|
22
21
|
export default defineConfig({
|
23
22
|
output: {
|
24
23
|
ssg: true,
|
@@ -38,14 +37,14 @@ For example, the following is a project directory structure using conventional r
|
|
38
37
|
```bash
|
39
38
|
.
|
40
39
|
├── src
|
41
|
-
│
|
42
|
-
│
|
43
|
-
│
|
44
|
-
│
|
45
|
-
│
|
46
|
-
│
|
47
|
-
│
|
48
|
-
│
|
40
|
+
│ └── routes
|
41
|
+
│ ├── layout.tsx
|
42
|
+
│ ├── page.tsx
|
43
|
+
│ └── user
|
44
|
+
│ ├── layout.tsx
|
45
|
+
│ ├── page.tsx
|
46
|
+
│ └── profile
|
47
|
+
│ └── page.tsx
|
49
48
|
```
|
50
49
|
|
51
50
|
The above file directory will generate the following three routes:
|
@@ -107,11 +106,11 @@ export default defineConfig({
|
|
107
106
|
});
|
108
107
|
```
|
109
108
|
|
110
|
-
run `pnpm run build` and `pnpm run serve`,access `http://localhost:8080/about`. In the Preview view, you can see that the page has been rendered
|
109
|
+
run `pnpm run build` and `pnpm run serve`,access `http://localhost:8080/about`. In the Preview view, you can see that the page has been rendered.
|
111
110
|
|
112
111
|
Looking at the bundle file, a new `main/about/index.html` file has been added in the `dist/` directory.
|
113
112
|
|
114
113
|
:::info
|
115
|
-
The above only introduces the single entry, more related content can be viewed [SSG API](/configure/app/output/ssg)
|
114
|
+
The above only introduces the single entry, more related content can be viewed [SSG API](/configure/app/output/ssg).
|
116
115
|
|
117
116
|
:::
|
@@ -44,7 +44,7 @@ And it provides elegant degradation processing. Once the SSR request fails, it w
|
|
44
44
|
However, developers still need to pay attention to the fallback of data, such as `null` values or data returns that do not as expect. Avoid React rendering errors or messy rendering results when SSR.
|
45
45
|
|
46
46
|
:::info
|
47
|
-
When using Data Loader, data fetching happens before rendering, Modern.js still supports fetching data when the component is rendered. See [Data Fetch](/guides/basic-features/data-fetch)
|
47
|
+
When using Data Loader, data fetching happens before rendering, Modern.js still supports fetching data when the component is rendered. See [Data Fetch](/guides/basic-features/data-fetch).
|
48
48
|
|
49
49
|
:::
|
50
50
|
|
@@ -198,7 +198,7 @@ This is because in the previous request, the SPR has asynchronously obtained the
|
|
198
198
|
It is conceivable that when `interval` is set to 1, users can have the responsive experience of a static page.
|
199
199
|
|
200
200
|
:::info
|
201
|
-
For more detail, see [`<PreRender>`](/apis/app/runtime/ssr/pre-render)
|
201
|
+
For more detail, see [`<PreRender>`](/apis/app/runtime/ssr/pre-render).
|
202
202
|
|
203
203
|
:::
|
204
204
|
|
@@ -276,7 +276,7 @@ export const loader = () => {
|
|
276
276
|
|
277
277
|
### Independent File
|
278
278
|
|
279
|
-
Both of the above methods will bring some burden to the developer. Modern.js based on [Nested Routing](/guides/basic-features/routes) developed and designed [Data Fetch](/guides/basic-features/data-fetch) to separate CSR and SSR code
|
279
|
+
Both of the above methods will bring some burden to the developer. Modern.js based on [Nested Routing](/guides/basic-features/routes) developed and designed [Data Fetch](/guides/basic-features/data-fetch) to separate CSR and SSR code.
|
280
280
|
|
281
281
|
## Remote Request
|
282
282
|
|
@@ -9,8 +9,8 @@ Modern.js inherits the testing capabilities of [Jest](https://jestjs.io/) by def
|
|
9
9
|
First need to execute `pnpm run new` enable [unit test/integration test] features:
|
10
10
|
|
11
11
|
```
|
12
|
-
?
|
13
|
-
?
|
12
|
+
? Action: Enable features
|
13
|
+
? Enable features: Enable Unit Test / Integration Test
|
14
14
|
```
|
15
15
|
|
16
16
|
After executing the above command, the `"test": "modern test"` command will be automatically generated in package.json.
|
@@ -20,7 +20,6 @@ register plugin in `modern.config.ts`:
|
|
20
20
|
```ts title="modern.config.ts"
|
21
21
|
import testPlugin from '@modern-js/plugin-testing';
|
22
22
|
|
23
|
-
// https://modernjs.dev/docs/apis/app/config
|
24
23
|
export default defineConfig({
|
25
24
|
plugins: [..., testPlugin()],
|
26
25
|
});
|
@@ -28,7 +27,7 @@ export default defineConfig({
|
|
28
27
|
|
29
28
|
## Test file
|
30
29
|
|
31
|
-
Modern.js default recognized test file paths are: `<rootDir>/src/**/*.test.[jt]s?(x)` and `<rootDir>/tests/**/*.test.[jt]s?(x)
|
30
|
+
Modern.js default recognized test file paths are: `<rootDir>/src/**/*.test.[jt]s?(x)` and `<rootDir>/tests/**/*.test.[jt]s?(x)`.
|
32
31
|
|
33
32
|
If you need to customize the test directory, you can configure it with [tools.jest](/configure/app/tools/jest).
|
34
33
|
|
@@ -40,7 +39,7 @@ Modern.js test support [testing-library](https://testing-library.com/docs/). API
|
|
40
39
|
import { render, screen } from '@modern-js/runtime/testing';
|
41
40
|
```
|
42
41
|
|
43
|
-
Other Modern.js supported testing APIs can be found [here](/apis/app/runtime/testing/cleanup)
|
42
|
+
Other Modern.js supported testing APIs can be found [here](/apis/app/runtime/testing/cleanup).
|
44
43
|
|
45
44
|
## transform
|
46
45
|
|
@@ -23,10 +23,10 @@ For example, import the modules from the `src/common/` directory in the `src/App
|
|
23
23
|
```bash
|
24
24
|
.
|
25
25
|
├── common
|
26
|
-
│
|
27
|
-
│
|
28
|
-
│
|
29
|
-
│
|
26
|
+
│ ├── styles
|
27
|
+
│ │ └── base.css
|
28
|
+
│ └── utils
|
29
|
+
│ └── index.ts
|
30
30
|
├── App.tsx
|
31
31
|
```
|
32
32
|
|
@@ -62,4 +62,4 @@ export default defineConfig({
|
|
62
62
|
});
|
63
63
|
```
|
64
64
|
|
65
|
-
|
65
|
+
For detailed usage, please refer to [source.alias documentation](/configure/app/source/alias).
|
@@ -81,16 +81,16 @@ When a routing file is passed through `[]`, it is passed as a [dynamic route](/g
|
|
81
81
|
|
82
82
|
```tsx
|
83
83
|
// routes/user/[id]/page.loader.tsx
|
84
|
-
import {
|
84
|
+
import { LoaderFunctionArgs } from '@modern-js/runtime/router';
|
85
85
|
|
86
|
-
export default async ({ params }:
|
86
|
+
export default async ({ params }: LoaderFunctionArgs) => {
|
87
87
|
const { id } = params;
|
88
88
|
const res = await fetch(`https://api/user/${id}`);
|
89
89
|
return res.json();
|
90
90
|
};
|
91
91
|
```
|
92
92
|
|
93
|
-
|
93
|
+
When accessing `/user/123`, the parameters of the `loader` function are `{ params: { id: '123' } }`.
|
94
94
|
|
95
95
|
#### `request`
|
96
96
|
|
@@ -100,9 +100,9 @@ A common usage scenario is to obtain query parameters via `request`:
|
|
100
100
|
|
101
101
|
```tsx
|
102
102
|
// routes/user/[id]/page.loader.ts
|
103
|
-
import {
|
103
|
+
import { LoaderFunctionArgs } from '@modern-js/runtime/router';
|
104
104
|
|
105
|
-
export default async ({ request }:
|
105
|
+
export default async ({ request }: LoaderFunctionArgs) => {
|
106
106
|
const url = new URL(request.url);
|
107
107
|
const userId = url.searchParams.get('id');
|
108
108
|
return queryUser(userId);
|
@@ -220,6 +220,26 @@ Currently, only CSR is supported, so stay tuned for Streaming SSR.
|
|
220
220
|
|
221
221
|
:::
|
222
222
|
|
223
|
+
Add the following code to `user/layout.loader.ts`:
|
224
|
+
|
225
|
+
```ts title="routes/user/layout.loader.ts"
|
226
|
+
import { defer } from "@edenx/runtime/router"
|
227
|
+
|
228
|
+
const loader = () =>
|
229
|
+
defer({
|
230
|
+
userInfo: new Promise((resolve) => {
|
231
|
+
setTimeout(() => {
|
232
|
+
resolve({
|
233
|
+
age: 1,
|
234
|
+
name: 'user layout'
|
235
|
+
})
|
236
|
+
}, 1000)
|
237
|
+
})
|
238
|
+
})
|
239
|
+
|
240
|
+
export default loader;
|
241
|
+
```
|
242
|
+
|
223
243
|
Add the following code to `user/layout.tsx`:
|
224
244
|
|
225
245
|
```tsx title="routes/user/layout.tsx"
|
@@ -230,13 +250,6 @@ import {
|
|
230
250
|
Outlet
|
231
251
|
} from '@modern-js/runtime/router';
|
232
252
|
|
233
|
-
export const loader = () => {
|
234
|
-
return defer({
|
235
|
-
// fetchUserInfo 是一个异步函数,返回用户信息
|
236
|
-
userInfo: fetchUserInfo(),
|
237
|
-
})
|
238
|
-
}
|
239
|
-
|
240
253
|
export default function UserLayout() {
|
241
254
|
const { userInfo } = useLoaderData() as {userInfo: Promise<UserInfo>};
|
242
255
|
return (
|
@@ -167,4 +167,4 @@ const foo = TWO;
|
|
167
167
|
const foo = 1 + 1;
|
168
168
|
```
|
169
169
|
|
170
|
-
In most cases, `source.globalVars` is already sufficient to replace variables. But the values passed in by `source.globalVars` will be serialized by JSON by default. So it cannot be replaced like `1 + 1` in the example above,at this time, we need use [`source.define`](/configure/app/source/define)
|
170
|
+
In most cases, `source.globalVars` is already sufficient to replace variables. But the values passed in by `source.globalVars` will be serialized by JSON by default. So it cannot be replaced like `1 + 1` in the example above,at this time, we need use [`source.define`](/configure/app/source/define).
|
@@ -4,7 +4,7 @@ sidebar_position: 9
|
|
4
4
|
---
|
5
5
|
# HTML Template
|
6
6
|
|
7
|
-
Modern.js provides **JSX syntax** and **HTML(
|
7
|
+
Modern.js provides **JSX syntax** and **HTML(EJS) syntax** for customizing HTML template.
|
8
8
|
|
9
9
|
## JSX syntax
|
10
10
|
|
@@ -14,14 +14,14 @@ For example the following directory structure:
|
|
14
14
|
|
15
15
|
```bash
|
16
16
|
.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
│
|
21
|
-
│
|
22
|
-
|
23
|
-
│
|
24
|
-
|
17
|
+
└── src
|
18
|
+
├── Document.tsx
|
19
|
+
├── entry-a
|
20
|
+
│ ├── Document.tsx
|
21
|
+
│ └── routes
|
22
|
+
├── entry-b
|
23
|
+
│ └── routes
|
24
|
+
└── modern-app-env.d.ts
|
25
25
|
```
|
26
26
|
|
27
27
|
`entry-a` will take precedence over the `Docoument.[jt]sx` file under the current entry. If the current entry does not have a `Document.[jt]sx` file, such as `entry-b`, it will look for the `Document.[jt]sx` file in the root directory.
|
@@ -42,7 +42,7 @@ These components are rendered:
|
|
42
42
|
|
43
43
|
- `Body`:Provide the ability of native Body Element, which needs to contain the `<Root>` component internally, and also supports other elements as child elements at the same time, such as adding footers.
|
44
44
|
|
45
|
-
- `Root`:React root element `<div id='root'></div
|
45
|
+
- `Root`:React root element `<div id='root'></div>`. the default element id is `id = 'root'`, can set `props.rootId` to change the id.Child components can be added, and will also be rendered into HTML templates, which will be overwritten when React rendering is complete, generally used to implement global Loading.
|
46
46
|
|
47
47
|
- `Head`:Provides native Head Element capabilities and automatically populates `<meta>`, as well as the `<Scripts>` component.
|
48
48
|
|
@@ -193,7 +193,7 @@ In the application root directory, create the `config/html/` directory, which su
|
|
193
193
|
</html>
|
194
194
|
```
|
195
195
|
|
196
|
-
HTML Fragments support the use [Lodash template](https://lodash.com/docs/4.17.15#template)
|
196
|
+
HTML Fragments support the use [Lodash template](https://lodash.com/docs/4.17.15#template).
|
197
197
|
|
198
198
|
For example, insert a script in `body.html`:
|
199
199
|
|
@@ -40,7 +40,7 @@ export default {
|
|
40
40
|
};
|
41
41
|
```
|
42
42
|
|
43
|
-
when access `http://localhost:8080/api/getInfo`, the api will return json `{ "data": [1, 2, 3, 4] }
|
43
|
+
when access `http://localhost:8080/api/getInfo`, the api will return json `{ "data": [1, 2, 3, 4] }`.
|
44
44
|
|
45
45
|
## Return Random Data
|
46
46
|
|
@@ -77,3 +77,23 @@ export default {
|
|
77
77
|
},
|
78
78
|
};
|
79
79
|
```
|
80
|
+
|
81
|
+
## Use Mock On Demand
|
82
|
+
|
83
|
+
Under the `config/mock/index.ts`, you can also export the `config` to control the Mock service.
|
84
|
+
|
85
|
+
```ts
|
86
|
+
type MockConfig = {
|
87
|
+
enable: ((req: IncomingMessage, res: ServerResponse) => boolean) | boolean;
|
88
|
+
};
|
89
|
+
|
90
|
+
export const config = {
|
91
|
+
enable: false
|
92
|
+
}
|
93
|
+
```
|
94
|
+
|
95
|
+
Currently only the `enable` configuration is supported, through which developers can control whether to execute Mock.
|
96
|
+
|
97
|
+
:::note
|
98
|
+
After modifying `config`, there is no need to restart the service, which will take effect immediately.
|
99
|
+
:::
|
@@ -6,7 +6,7 @@ sidebar_position: 5
|
|
6
6
|
|
7
7
|
## Local Proxy
|
8
8
|
|
9
|
-
Modern.js provides a way to configure the development proxy in [
|
9
|
+
Modern.js provides a way to configure the development proxy in [tools.devServer](/configure/app/tools/dev-server). For example, to proxy the local interface to an online address:
|
10
10
|
|
11
11
|
```ts title="modern.config.ts"
|
12
12
|
import { defineConfig } from '@modern-js/app-tools';
|
@@ -28,7 +28,7 @@ export default defineConfig({
|
|
28
28
|
when access `http://localhost:8080/go/api`, the response content is returned from [http://www.example.com/](http://www.example.com/).
|
29
29
|
|
30
30
|
:::info
|
31
|
-
For more detail, see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware)
|
31
|
+
For more detail, see [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware).
|
32
32
|
|
33
33
|
:::
|
34
34
|
|
@@ -77,7 +77,7 @@ In order to facilitate the introduction of the relationship between `<Layout>` a
|
|
77
77
|
.
|
78
78
|
└── routes
|
79
79
|
├── blog
|
80
|
-
│
|
80
|
+
│ └── page.tsx
|
81
81
|
├── layout.tsx
|
82
82
|
├── page.tsx
|
83
83
|
└── user
|
@@ -124,15 +124,15 @@ With a file directory named `[]`, the generated route will be used as a dynamic
|
|
124
124
|
```
|
125
125
|
└── routes
|
126
126
|
├── [id]
|
127
|
-
│
|
127
|
+
│ └── page.tsx
|
128
128
|
├── blog
|
129
|
-
│
|
129
|
+
│ └── page.tsx
|
130
130
|
└── page.tsx
|
131
131
|
```
|
132
132
|
|
133
133
|
The `routes/[id]/page.tsx` file is converted to the `/:id` route. Except for the `/blog` route that exactly matches, all other `/xxx` will match this route.
|
134
134
|
|
135
|
-
In component, you can get the corresponding named parameters through [useParams](/apis/app/runtime/router
|
135
|
+
In component, you can get the corresponding named parameters through [useParams](/apis/app/runtime/router/router#useparams).
|
136
136
|
|
137
137
|
### Catch all routing
|
138
138
|
|
@@ -148,11 +148,11 @@ For example, the following directory structure:
|
|
148
148
|
└── routes
|
149
149
|
├── $.tsx
|
150
150
|
├── blog
|
151
|
-
│
|
151
|
+
│ └── page.tsx
|
152
152
|
└── page.tsx
|
153
153
|
```
|
154
154
|
|
155
|
-
The `routes/$.tsx` component is rendered when accessing any path that does not match, and again, the remainder of the url can be captured in `$.tsx` using [useParams](/apis/app/runtime/router
|
155
|
+
The `routes/$.tsx` component is rendered when accessing any path that does not match, and again, the remainder of the url can be captured in `$.tsx` using [useParams](/apis/app/runtime/router/router#useparams).
|
156
156
|
|
157
157
|
```ts title="$.tsx"
|
158
158
|
import { useParams } from '@modern-js/runtime/router';
|
@@ -215,9 +215,9 @@ When the component exists in the routing directory, all routing switches under t
|
|
215
215
|
.
|
216
216
|
└── routes
|
217
217
|
├── blog
|
218
|
-
│
|
219
|
-
│
|
220
|
-
│
|
218
|
+
│ ├── [id]
|
219
|
+
│ │ └── page.tsx
|
220
|
+
│ └── page.tsx
|
221
221
|
├── layout.tsx
|
222
222
|
├── loading.tsx
|
223
223
|
└── page.tsx
|
@@ -225,6 +225,22 @@ When the component exists in the routing directory, all routing switches under t
|
|
225
225
|
|
226
226
|
When a route jumps from `/` to `/blog`, if the JS Chunk of the `<Blog>` component is not loaded, the component UI exported in `loading.tsx` will be displayed first. But when jumping from `/blog` to `/blog/20220101`, it will not be displayed.
|
227
227
|
|
228
|
+
### Redirect
|
229
|
+
|
230
|
+
You can redirect routes by creating a [`data loader`](/guides/basic-features/data-fetch) file, Suppose you have the file `routes/user/page.tsx` and you want to redirect the route corresponding to this file, you can create the file `routes/user/page.loader.ts`:
|
231
|
+
|
232
|
+
```ts title="routes/user/page.loader.ts"
|
233
|
+
import { redirect } from "@edenx/runtime/router"
|
234
|
+
|
235
|
+
export default () => {
|
236
|
+
const user = await getUser();
|
237
|
+
if(!user){
|
238
|
+
return redirect('/login');
|
239
|
+
}
|
240
|
+
return null;
|
241
|
+
}
|
242
|
+
```
|
243
|
+
|
228
244
|
### ErrorBoundary
|
229
245
|
|
230
246
|
In each layer directory under `routes/`, the developer can also define a `error.tsx` file, and export a `<ErrorBoundary>` component by default.
|
@@ -235,7 +251,7 @@ When the component exists in a routing directory, the component render error is
|
|
235
251
|
|
236
252
|
{/* Todo API 路由 */}
|
237
253
|
|
238
|
-
Within the `<ErrorBoundary>` component, you can use [useRouteError](/apis/app/runtime/router
|
254
|
+
Within the `<ErrorBoundary>` component, you can use [useRouteError](/apis/app/runtime/router/router#useparams) to get the specific information of the error:
|
239
255
|
|
240
256
|
```tsx
|
241
257
|
import { useRouteError } from '@modern-js/runtime/router';
|
@@ -295,19 +311,17 @@ export default () => {
|
|
295
311
|
When working with SSR, the browser side can get the data returned by `init` during SSR, and the developer can decide whether to retrieve the data on the browser side to overwrite the SSR data, for example:
|
296
312
|
|
297
313
|
```tsx title="src/routes/layout.tsx"
|
298
|
-
import {
|
299
|
-
RuntimeContext,
|
300
|
-
} from '@modern-js/runtime';
|
314
|
+
import { RuntimeContext } from '@modern-js/runtime';
|
301
315
|
|
302
316
|
export const init = (context: RuntimeContext) => {
|
303
|
-
if (process.env.
|
317
|
+
if (process.env.MODERN_TARGET === 'node') {
|
304
318
|
return {
|
305
319
|
message: 'Hello World By Server',
|
306
320
|
}
|
307
321
|
} else {
|
308
322
|
const { context } = runtimeContext;
|
309
323
|
const data = context.getInitData();
|
310
|
-
//
|
324
|
+
// If do not get the expected data
|
311
325
|
if (!data.message) {
|
312
326
|
return {
|
313
327
|
message: 'Hello World By Client'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
title: Builder
|
3
2
|
sidebar_position: 2
|
4
3
|
---
|
4
|
+
|
5
5
|
# Builder
|
6
6
|
|
7
7
|
**Modern.js uses [Modern.js Builder](https://modernjs.dev/builder) to build your Web App.**
|
@@ -14,7 +14,7 @@ From the perspective of building, Modern.js is divided into three layers, from t
|
|
14
14
|
|
15
15
|
- Upper-layer framework: Modern.js.
|
16
16
|
- Universal build engine: Modern.js Builder.
|
17
|
-
- Low-level bundlers: webpack and
|
17
|
+
- Low-level bundlers: webpack and rspack.
|
18
18
|
|
19
19
|
<img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-1117.png" style={{ maxWidth: '540px' }} />
|
20
20
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
sidebar_position: 2
|
2
|
+
sidebar_position: 1
|
4
3
|
---
|
4
|
+
|
5
5
|
# Entries
|
6
6
|
|
7
7
|
Entries are Modern.js default file convention, and each entry in the project is a separate page, corresponding to a server level route.
|
@@ -15,11 +15,11 @@ Modern.js initialization project is a single entry, the project structure is as
|
|
15
15
|
```
|
16
16
|
.
|
17
17
|
├── src
|
18
|
-
│
|
19
|
-
│
|
20
|
-
│
|
21
|
-
│
|
22
|
-
│
|
18
|
+
│ ├── modern-app-env.d.ts
|
19
|
+
│ └── routes
|
20
|
+
│ ├── index.css
|
21
|
+
│ ├── layout.tsx
|
22
|
+
│ └── page.tsx
|
23
23
|
├── package.json
|
24
24
|
├── modern.config.ts
|
25
25
|
├── pnpm-lock.yaml
|
@@ -41,10 +41,10 @@ After execution, the `src/` directory will become the following structure:
|
|
41
41
|
.
|
42
42
|
├── modern-app-env.d.ts
|
43
43
|
├── myapp
|
44
|
-
│
|
45
|
-
│
|
46
|
-
│
|
47
|
-
│
|
44
|
+
│ └── routes
|
45
|
+
│ ├── index.css
|
46
|
+
│ ├── layout.tsx
|
47
|
+
│ └── page.tsx
|
48
48
|
└── new-entry
|
49
49
|
└── routes
|
50
50
|
├── index.css
|
@@ -12,6 +12,6 @@ sidebar_position: 4
|
|
12
12
|
- If you need to customize the configuration of [sass-loader](https://github.com/webpack-contrib/sass-loader), please refer to the [tools.less](/configure/app/tools/sass).
|
13
13
|
|
14
14
|
:::tip
|
15
|
-
CSS files pre-compiled by Less and Sass will still undergo Modern.js build-in [PostCSS](https://postcss.org/) conversion, which has good browser compatibility. For related content, please refer to [[PostCSS](/guides/
|
15
|
+
CSS files pre-compiled by Less and Sass will still undergo Modern.js build-in [PostCSS](https://postcss.org/) conversion, which has good browser compatibility. For related content, please refer to [[PostCSS](/guides/css/postcss)].
|
16
16
|
|
17
17
|
:::
|
@@ -0,0 +1,34 @@
|
|
1
|
+
---
|
2
|
+
title: Introduction
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
# Introduction
|
6
|
+
|
7
|
+
## Modern.js Introduction
|
8
|
+
|
9
|
+
**Modern.js** is a progressive modern web development framework based on React.
|
10
|
+
|
11
|
+
The framework has a variety of built-in out-of-the-box tools, excellent build performance, zero-configuration rendering paradigm switching, and integrated API calls. Starting from three solutions (Application solutions, Module solutions, Monorepo solutions), it supports front-end research and development of a complete period.
|
12
|
+
|
13
|
+
Modern.js is ByteDance's underlying front-end framework, which has directly or indirectly served thousands of applications, including middle and back-end, PC Web, H5 and other application scenarios. The framework covers a full life cycle, has a complete plugin system, and provides a high degree of customization capabilities. Support custom solutions exclusive to business lines through generator plugin, customize various functional extensions and business requirements, and help developers build applications faster.
|
14
|
+
|
15
|
+
## Why Modern.js
|
16
|
+
|
17
|
+
Modern.js can provide developers with the ultimate **Development Experience**,make the app better **User Experience**.
|
18
|
+
|
19
|
+
In the process of developing React applications, developers often need to design implementations for certain functions, or use other libraries and frameworks to solve these problems.
|
20
|
+
|
21
|
+
Modern.js support all the configuration and tools required by React applications, and have built-in **additional functions and optimizations**. Developers can use React to build the UI of the application, and then gradually adopt Modern.js functions to solve common application requirements, such as routing, data fetch, state management, etc.
|
22
|
+
|
23
|
+
It mainly contains the following features:
|
24
|
+
|
25
|
+
- 🪜 **Progressive**:Create projects with the most streamlined templates, gradually turn on plugin capabilities through generators, and customize solutions.
|
26
|
+
- 🏠 **Integration**:The development is unique to the production environment Web Server, CSR and SSR are isomorphic development, and the function as the API service call.
|
27
|
+
- 📦 **Out Of The Box**:Default TS support, built-in build core, ESLint, debugging tools, full functionality can be tested.
|
28
|
+
- 🌏 **Ecology**:Self-developed state management, micro frontend, module packaging, Monorepo solution and other peripheral requirements.
|
29
|
+
- 🕸 **Routing Modes**:Contains controlled routing, routing based on file conventions (nested routing), configurable routing, etc.
|
30
|
+
- 🚀 **Independently Build Core**:Support a variety of packaging tools, deep optimization bundle.
|
31
|
+
|
32
|
+
## Next
|
33
|
+
|
34
|
+
If you want to know how to use Modern.js, you can try [Create your first app](/tutorials/first-app/c01-start), or read [Quick Start](/guides/get-started/quick-start).
|
@@ -1,7 +1,8 @@
|
|
1
1
|
---
|
2
2
|
title: Quick Start
|
3
|
-
sidebar_position:
|
3
|
+
sidebar_position: 2
|
4
4
|
---
|
5
|
+
|
5
6
|
# Quick Start
|
6
7
|
|
7
8
|
## Environment
|
@@ -81,7 +82,6 @@ Features can be enabled through the configuration file, or the default behavior
|
|
81
82
|
```ts
|
82
83
|
import { defineConfig } from '@modern-js/app-tools';
|
83
84
|
|
84
|
-
// https://modernjs.dev/docs/apis/app/config
|
85
85
|
export default defineConfig({
|
86
86
|
runtime: {
|
87
87
|
router: true,
|
@@ -129,9 +129,9 @@ The bundle is generated to `dist/` by default, and the directory structure is as
|
|
129
129
|
.
|
130
130
|
├── asset-manifest.json
|
131
131
|
├── html
|
132
|
-
│
|
132
|
+
│ └── main
|
133
133
|
├── loader-routes
|
134
|
-
│
|
134
|
+
│ └── main
|
135
135
|
├── modern.config.json
|
136
136
|
├── route.json
|
137
137
|
└── static
|