@modern-js/main-doc 2.58.2 → 2.59.0
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/en/apis/app/runtime/core/use-loader.mdx +1 -1
- package/docs/en/community/blog/_meta.json +1 -6
- package/docs/en/components/deploy.mdx +1 -1
- package/docs/en/components/init-app.mdx +0 -1
- package/docs/en/components/init-rspack-app.mdx +0 -1
- package/docs/en/components/ssr-monitor.mdx +3 -0
- package/docs/en/configure/_meta.json +1 -1
- package/docs/en/configure/app/output/ssg.mdx +52 -141
- package/docs/en/configure/app/tools/swc.mdx +1 -1
- package/docs/en/configure/app/tools/tailwindcss.mdx +1 -1
- package/docs/en/guides/advanced-features/_meta.json +0 -8
- package/docs/en/guides/advanced-features/bff/_meta.json +1 -6
- package/docs/en/guides/advanced-features/rsbuild-plugin.mdx +2 -2
- package/docs/en/guides/advanced-features/rspack-start.mdx +7 -22
- package/docs/en/guides/basic-features/_meta.json +31 -9
- package/docs/en/guides/basic-features/css/_meta.json +1 -0
- package/docs/en/guides/basic-features/css/css-in-js.mdx +34 -0
- package/docs/en/guides/basic-features/{css-modules.mdx → css/css-modules.mdx} +0 -4
- package/docs/en/guides/basic-features/css/css.mdx +25 -0
- package/docs/en/guides/basic-features/{css.mdx → css/tailwindcss.mdx} +5 -66
- package/docs/en/guides/basic-features/data/_meta.json +1 -4
- package/docs/en/guides/basic-features/data/data-fetch.mdx +134 -235
- package/docs/en/guides/basic-features/data/data-write.mdx +66 -77
- package/docs/en/guides/basic-features/debug/_meta.json +1 -0
- package/docs/en/guides/basic-features/debug/rsdoctor.mdx +57 -0
- package/docs/en/guides/{advanced-features → basic-features/debug}/using-storybook.mdx +2 -0
- package/docs/en/guides/basic-features/render/_meta.json +1 -0
- package/docs/en/guides/basic-features/render/ssg.mdx +208 -0
- package/docs/en/guides/{advanced-features/ssr/cache.mdx → basic-features/render/ssr-cache.mdx} +38 -50
- package/docs/en/guides/basic-features/render/ssr.mdx +301 -0
- package/docs/en/guides/basic-features/render/streaming-ssr.mdx +230 -0
- package/docs/en/guides/basic-features/routes.mdx +275 -263
- package/docs/en/guides/basic-features/static-assets/_meta.json +1 -0
- package/docs/en/guides/basic-features/static-assets.mdx +1 -1
- package/docs/en/guides/basic-features/testing/_meta.json +1 -0
- package/docs/en/guides/basic-features/testing/cypress.mdx +95 -0
- package/docs/en/guides/basic-features/testing/jest.mdx +148 -0
- package/docs/en/guides/basic-features/testing/playwright.mdx +111 -0
- package/docs/en/guides/basic-features/testing/vitest.mdx +100 -0
- package/docs/en/guides/concept/_meta.json +1 -4
- package/docs/en/guides/concept/entries.mdx +78 -47
- package/docs/en/guides/get-started/_meta.json +1 -7
- package/docs/en/guides/get-started/introduction.mdx +1 -1
- package/docs/en/guides/get-started/quick-start.mdx +1 -2
- package/docs/en/guides/get-started/tech-stack.mdx +4 -6
- package/docs/en/guides/get-started/upgrade.mdx +16 -2
- package/docs/en/guides/topic-detail/framework-plugin/_meta.json +1 -1
- package/docs/en/guides/topic-detail/generator/_meta.json +1 -1
- package/docs/en/guides/topic-detail/generator/create/_meta.json +1 -5
- package/docs/en/guides/topic-detail/generator/create/config.mdx +0 -10
- package/docs/en/guides/topic-detail/generator/create/use.mdx +0 -1
- package/docs/en/guides/topic-detail/generator/new/_meta.json +1 -5
- package/docs/en/guides/topic-detail/generator/plugin/_meta.json +1 -1
- package/docs/en/guides/troubleshooting/_meta.json +1 -6
- package/docs/en/tutorials/first-app/c03-css.mdx +1 -1
- package/docs/zh/apis/app/runtime/core/use-loader.mdx +1 -1
- package/docs/zh/community/blog/_meta.json +1 -6
- package/docs/zh/components/deploy.mdx +1 -1
- package/docs/zh/components/init-app.mdx +0 -1
- package/docs/zh/components/init-rspack-app.mdx +0 -1
- package/docs/zh/components/ssr-monitor.mdx +3 -0
- package/docs/zh/configure/_meta.json +1 -1
- package/docs/zh/configure/app/output/ssg.mdx +49 -139
- package/docs/zh/configure/app/tools/swc.mdx +1 -1
- package/docs/zh/configure/app/tools/tailwindcss.mdx +1 -1
- package/docs/zh/guides/advanced-features/_meta.json +0 -8
- package/docs/zh/guides/advanced-features/bff/_meta.json +1 -6
- package/docs/zh/guides/advanced-features/rsbuild-plugin.mdx +2 -2
- package/docs/zh/guides/advanced-features/rspack-start.mdx +8 -24
- package/docs/zh/guides/basic-features/_meta.json +31 -9
- package/docs/zh/guides/basic-features/css/_meta.json +1 -0
- package/docs/zh/guides/basic-features/css/css-in-js.mdx +34 -0
- package/docs/zh/guides/basic-features/css/css.mdx +25 -0
- package/docs/zh/guides/basic-features/{css.mdx → css/tailwindcss.mdx} +3 -64
- package/docs/zh/guides/basic-features/data/_meta.json +1 -4
- package/docs/zh/guides/basic-features/data/data-fetch.mdx +98 -214
- package/docs/zh/guides/basic-features/data/data-write.mdx +54 -55
- package/docs/zh/guides/basic-features/debug/_meta.json +1 -0
- package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +57 -0
- package/docs/zh/guides/{advanced-features → basic-features/debug}/using-storybook.mdx +1 -1
- package/docs/zh/guides/basic-features/render/_meta.json +1 -0
- package/docs/zh/guides/basic-features/render/ssg.mdx +210 -0
- package/docs/zh/guides/{advanced-features/ssr/cache.mdx → basic-features/render/ssr-cache.mdx} +16 -26
- package/docs/zh/guides/basic-features/render/ssr.mdx +309 -0
- package/docs/zh/guides/{advanced-features/ssr/stream.mdx → basic-features/render/streaming-ssr.mdx} +22 -37
- package/docs/zh/guides/basic-features/routes.mdx +252 -237
- package/docs/zh/guides/basic-features/static-assets/_meta.json +1 -0
- package/docs/zh/guides/basic-features/static-assets.mdx +2 -6
- package/docs/zh/guides/basic-features/testing/_meta.json +1 -0
- package/docs/zh/guides/basic-features/testing/cypress.mdx +95 -0
- package/docs/zh/guides/basic-features/testing/jest.mdx +148 -0
- package/docs/zh/guides/basic-features/testing/playwright.mdx +112 -0
- package/docs/zh/guides/basic-features/testing/vitest.mdx +100 -0
- package/docs/zh/guides/concept/_meta.json +1 -4
- package/docs/zh/guides/concept/entries.mdx +80 -58
- package/docs/zh/guides/get-started/_meta.json +1 -7
- package/docs/zh/guides/get-started/introduction.mdx +2 -2
- package/docs/zh/guides/get-started/quick-start.mdx +1 -2
- package/docs/zh/guides/get-started/tech-stack.mdx +8 -10
- package/docs/zh/guides/get-started/upgrade.mdx +15 -1
- package/docs/zh/guides/topic-detail/framework-plugin/_meta.json +1 -1
- package/docs/zh/guides/topic-detail/generator/_meta.json +1 -1
- package/docs/zh/guides/topic-detail/generator/create/_meta.json +1 -5
- package/docs/zh/guides/topic-detail/generator/create/config.mdx +0 -10
- package/docs/zh/guides/topic-detail/generator/create/use.mdx +0 -1
- package/docs/zh/guides/topic-detail/generator/new/_meta.json +1 -5
- package/docs/zh/guides/topic-detail/generator/plugin/_meta.json +1 -1
- package/docs/zh/guides/troubleshooting/_meta.json +1 -6
- package/docs/zh/tutorials/first-app/c03-css.mdx +1 -1
- package/i18n.json +16 -4
- package/package.json +6 -6
- package/rspress.config.ts +1 -1
- package/src/components/ContentCard/index.tsx +1 -1
- package/src/components/Sandpack/index.tsx +1 -1
- package/src/components/ShowcaseList/index.tsx +1 -1
- package/src/i18n/index.ts +1 -1
- package/src/pages/index.tsx +2 -2
- package/docs/en/apis/app/hooks/config/storybook.mdx +0 -37
- package/docs/en/guides/advanced-features/ssg.mdx +0 -116
- package/docs/en/guides/advanced-features/ssr/_meta.json +0 -5
- package/docs/en/guides/advanced-features/ssr/index.mdx +0 -23
- package/docs/en/guides/advanced-features/ssr/stream.mdx +0 -248
- package/docs/en/guides/advanced-features/ssr/usage.mdx +0 -341
- package/docs/en/guides/advanced-features/ssr.mdx +0 -555
- package/docs/zh/apis/app/hooks/config/storybook.mdx +0 -38
- package/docs/zh/guides/advanced-features/ssg.mdx +0 -116
- package/docs/zh/guides/advanced-features/ssr/_meta.json +0 -5
- package/docs/zh/guides/advanced-features/ssr/index.mdx +0 -23
- package/docs/zh/guides/advanced-features/ssr/usage.mdx +0 -329
- /package/docs/en/guides/basic-features/{mock.mdx → debug/mock.mdx} +0 -0
- /package/docs/en/guides/basic-features/{proxy.mdx → debug/proxy.mdx} +0 -0
- /package/docs/en/guides/basic-features/{json-files.mdx → static-assets/json-files.mdx} +0 -0
- /package/docs/en/guides/basic-features/{svg-assets.mdx → static-assets/svg-assets.mdx} +0 -0
- /package/docs/en/guides/basic-features/{wasm-assets.mdx → static-assets/wasm-assets.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{css-modules.mdx → css/css-modules.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{mock.mdx → debug/mock.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{proxy.mdx → debug/proxy.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{json-files.mdx → static-assets/json-files.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{svg-assets.mdx → static-assets/svg-assets.mdx} +0 -0
- /package/docs/zh/guides/basic-features/{wasm-assets.mdx → static-assets/wasm-assets.mdx} +0 -0
@@ -16,7 +16,7 @@ Many configuration options provided by Modern.js are divided by entry, such as p
|
|
16
16
|
|
17
17
|
## Single Entry and Multiple Entries
|
18
18
|
|
19
|
-
The project initialized by Modern.js is a single entry
|
19
|
+
The project initialized by Modern.js is a single entry project, with the following structure:
|
20
20
|
|
21
21
|
```
|
22
22
|
.
|
@@ -56,13 +56,12 @@ After running the command, Modern.js will automatically generate a new entry dir
|
|
56
56
|
|
57
57
|
The original entry code has been moved to a directory with the same name as the `name` field in `package.json`, and a `new-entry` entry directory has been created.
|
58
58
|
|
59
|
-
You can run `pnpm run dev` to start the development server. At this point, you will see a new route named `/new-entry` added, and the existing page routes remain unchanged.
|
60
|
-
|
61
|
-
:::tip
|
62
59
|
Modern.js will use the entry with the same name as the `name` field in `package.json` as the main entry. The route of the main entry is `/`, and the route of other entries is `/{entryName}`.
|
63
60
|
|
64
|
-
|
61
|
+
You can run `pnpm run dev` to start the development server. At this point, you will see a new route named `/new-entry` added, and the existing page routes remain unchanged.
|
65
62
|
|
63
|
+
:::note
|
64
|
+
The concepts of **single entry/multiple entry** and **SPA/MPA** are not equivalent. The former pertains to how to configure and package the application, while the latter is about the patterns for organizing front-end applications. Each entry point can be either an SPA or a non-SPA.
|
66
65
|
:::
|
67
66
|
|
68
67
|
## Entry Types
|
@@ -82,30 +81,26 @@ By default, Modern.js scans the files under `src/` before starting the project,
|
|
82
81
|
|
83
82
|
:::
|
84
83
|
|
85
|
-
|
84
|
+
The entry directory must meet one of the following three conditions:
|
86
85
|
|
87
86
|
1. Has a `routes/` directory.
|
88
87
|
2. Has an `App.[jt]sx?` file.
|
89
|
-
|
90
|
-
4. Has a `pages/` directory (compatible with Modern.js 1.0).
|
91
|
-
5. Has an `entry.[jt]sx?` file.
|
88
|
+
5. Has an `entry.[jt]sx?` file.(Requires [source.enableCustomEntry](/configure/app/source/enable-custom-entry) to be enabled)
|
92
89
|
|
93
|
-
When the `src/` directory meets the entry
|
90
|
+
When the `src/` directory meets the conditions of an entry, Modern.js will consider the current application to be a single-entry application. Otherwise, Modern.js will scan the first-level directories under `src/` and further determine if they are entries. In this case, the application is typically a multi-entry application.
|
94
91
|
|
95
92
|
:::tip
|
96
93
|
In a single entry application, the default entry name is `main`.
|
97
94
|
|
98
95
|
:::
|
99
96
|
|
100
|
-
When the project is not a single entry application, Modern.js will further look at the top-level directories under `src/`.
|
101
|
-
|
102
97
|
### Framework Mode Entry
|
103
98
|
|
104
|
-
|
99
|
+
Framework mode refers to using Modern.js's framework capabilities, such as convention routing, SSR (Server-Side Rendering), and integrated calls. Under this type of entry convention, the entries in the application are not the actual compilation entries. Modern.js will generate a wrapped entry during startup, which you can find in `node_modules/.modern/[entryName]/index.js`.
|
105
100
|
|
106
101
|
#### Conventional Routing
|
107
102
|
|
108
|
-
If there is a `routes/` directory
|
103
|
+
If there is a `routes/` directory within the entry, we refer to this entry as a convention-based route. Modern.js will scan the files under `routes/` during startup and automatically generate client-side routes (react-router) based on file conventions. For example:
|
109
104
|
|
110
105
|
```bash
|
111
106
|
.
|
@@ -121,7 +116,19 @@ For more information, please refer to [Conventional Routing](/guides/basic-featu
|
|
121
116
|
|
122
117
|
#### Self-controlled Routing
|
123
118
|
|
124
|
-
|
119
|
+
## Manual Routing
|
120
|
+
|
121
|
+
If there is an `App.[jt]sx?` file within the entry, we refer to this entry as a self-controlled route. For example:
|
122
|
+
|
123
|
+
```bash
|
124
|
+
.
|
125
|
+
├── src
|
126
|
+
│ └── App.tsx
|
127
|
+
```
|
128
|
+
|
129
|
+
For entry points defined as `src/App.tsx`, Modern.js does not perform any additional routing operations. Developers can use the [React Router 6](https://reactrouter.com/en/main) API for development, define client-side routes or not to set any client-side routes.
|
130
|
+
|
131
|
+
for example, define client-side routes in application:
|
125
132
|
|
126
133
|
```tsx
|
127
134
|
import { BrowserRouter, Route, Routes } from '@modern-js/runtime/router';
|
@@ -138,16 +145,21 @@ export default () => {
|
|
138
145
|
};
|
139
146
|
```
|
140
147
|
|
141
|
-
|
148
|
+
:::note
|
149
|
+
We recommend that developers use conventional routing. Modern.js provides a series of optimizations in resource loading and rendering for conventional routing by default and offers built-in SSR capabilities. When using manual routing, these capabilities need to be encapsulated by developers themselves.
|
150
|
+
:::
|
142
151
|
|
143
|
-
#### Custom Entry
|
144
152
|
|
145
|
-
|
153
|
+
#### Custom Entry
|
146
154
|
|
147
155
|
:::info
|
148
|
-
Using this
|
156
|
+
Using this features requires enabling [source.enableCustomEntry](/configure/app/source/enable-custom-entry).
|
149
157
|
:::
|
150
158
|
|
159
|
+
By default, whether you use convention routing or self-controlled routing, Modern.js will automatically handle rendering. If you wish to customize this behavior, you can creating a custom entry file.
|
160
|
+
|
161
|
+
If there is an `entry.[jt]sx` file within the entry, Modern.js will no longer control the application's rendering process. You can call the `createRoot` and `render` functions within the `entry.[jt]sx` file to complete the entry logic for your application.
|
162
|
+
|
151
163
|
```tsx
|
152
164
|
import { createRoot } from '@modern-js/runtime/react';
|
153
165
|
import { render } from '@modern-js/runtime/browser';
|
@@ -157,7 +169,9 @@ const ModernRoot = createRoot();
|
|
157
169
|
render(<ModernRoot />);
|
158
170
|
```
|
159
171
|
|
160
|
-
|
172
|
+
In the code above, the component returned by the `createRoot` function is either the component generated from the `routes/` directory or the component exported by `App.tsx`.
|
173
|
+
|
174
|
+
The `render` function is used to handle rendering and mounting of the component. For example, if you want to execute some asynchronous tasks before rendering, you can achieve it like this:
|
161
175
|
|
162
176
|
```tsx
|
163
177
|
import { createRoot } from '@modern-js/runtime/react';
|
@@ -166,7 +180,7 @@ import { render } from '@modern-js/runtime/browser';
|
|
166
180
|
const ModernRoot = createRoot();
|
167
181
|
|
168
182
|
async function beforeRender() {
|
169
|
-
|
183
|
+
// some async request
|
170
184
|
}
|
171
185
|
|
172
186
|
beforeRender().then(() => {
|
@@ -174,34 +188,15 @@ beforeRender().then(() => {
|
|
174
188
|
});
|
175
189
|
```
|
176
190
|
|
177
|
-
#### Custom Bootstrap
|
178
|
-
|
179
|
-
:::warning
|
180
|
-
Soon to be deprecated, it is recommended to use a custom entry.
|
181
|
-
:::
|
182
|
-
|
183
|
-
If there is an `index.[jt]sx` file in the entry, and the file exports a function by default, Modern.js will pass the default `bootstrap` function as a parameter and use the exported function to replace the default `bootstrap`. This way, developers can customize how components are mounted to DOM nodes or add custom behavior before mounting. For example:
|
184
|
-
|
185
|
-
```tsx
|
186
|
-
export default (App: React.ComponentType, bootstrap: () => void) => {
|
187
|
-
// do something before bootstrap...
|
188
|
-
initSomething().then(() => {
|
189
|
-
bootstrap();
|
190
|
-
});
|
191
|
-
};
|
192
|
-
```
|
193
|
-
|
194
191
|
### Build Mode Entry
|
195
192
|
|
196
|
-
Build mode refers to not using the Runtime capabilities provided by Modern.js, but rather having the developer define the entry of the page completely on their own.
|
197
|
-
|
198
|
-
When the entry directory contains `index.[jt]sx` (soon to be deprecated) and does not export a function via `export default`, or when there is an `entry.[jt]sx` file in the entry directory and the `@modern-js/runtime` dependency is not installed, the corresponding file will be identified as the entry module of webpack or Rspack.
|
199
|
-
|
200
193
|
:::info
|
201
|
-
Using
|
194
|
+
Using this features requires enabling [source.enableCustomEntry](/configure/app/source/enable-custom-entry).
|
202
195
|
:::
|
203
196
|
|
204
|
-
|
197
|
+
Build mode refers to the development mode that does not use Modern.js's runtime capabilities and only utilizes Modern.js's build capabilities. When the `@modern-js/runtime` dependency is not installed in the application, Modern.js will treat all entries as build mode entries.
|
198
|
+
|
199
|
+
In this case, if there is an `entry.[jt]sx` file within the entry, this file will be recognized as the build entry for webpack or Rspack. Modern.js will not automatically generate entry code at this time, and you need to mount the component to the DOM node yourself. For example:
|
205
200
|
|
206
201
|
```js title=src/entry.tsx
|
207
202
|
import React from 'react';
|
@@ -211,9 +206,13 @@ import App from './App';
|
|
211
206
|
ReactDOM.render(<App />, document.getElementById('root'));
|
212
207
|
```
|
213
208
|
|
214
|
-
|
209
|
+
In build mode, the application **will not be able to use Modern.js's runtime capabilities**, such as:
|
210
|
+
- Convention routing, the routing based on the files under `src/routes`
|
211
|
+
- Server-Side Rendering (SSR)
|
212
|
+
- The `runtime` configuration in the `modern.config.js` file will no longer take effect
|
213
|
+
|
215
214
|
|
216
|
-
##
|
215
|
+
## Specify entry in the configuration file
|
217
216
|
|
218
217
|
In some cases, you may need to customize the entry configuration instead of using the entry conventions provided by Modern.js.
|
219
218
|
|
@@ -246,4 +245,36 @@ export default defineConfig({
|
|
246
245
|
});
|
247
246
|
```
|
248
247
|
|
249
|
-
|
248
|
+
It is worth noting that, by default, Modern.js considers entries specified through the configuration as **framework mode entries** and will automatically generate the actual compilation entry.
|
249
|
+
|
250
|
+
If your application is migrating from build tools like Webpack or Vite to the Modern.js framework, you typically need to enable the `disableMount` option in the entry configuration. In this case, Modern.js will treat the entry as a **build mode entry**.
|
251
|
+
|
252
|
+
## Deprecated
|
253
|
+
|
254
|
+
Currently, if the entry directory meets the following conditions, it will also be considered an application entry:
|
255
|
+
|
256
|
+
1. Has an `index.[jt]sx?` file.
|
257
|
+
2. Has a `pages/` directory.
|
258
|
+
|
259
|
+
The `pages/` directory was the convention routing in older versions of Modern.js. Now, it is recommended to use the `routes/` directory.
|
260
|
+
|
261
|
+
The `index.[jt]sx?` file supported **Custom Bootstrap** and **Build Mode Entry** in older versions. Now, it is recommended to use `entry.[jt]sx?` instead.
|
262
|
+
|
263
|
+
### Custom Bootstrap
|
264
|
+
|
265
|
+
When there is an `index.[jt]sx` file in the entry, and the file's default export is a function, Modern.js will pass the default `bootstrap` function as an argument and use the exported function to replace the default `bootstrap`.
|
266
|
+
|
267
|
+
This allows developers to customize mounting components to DOM or add custom behaviors before mounting. For example:
|
268
|
+
|
269
|
+
```tsx
|
270
|
+
export default (App: React.ComponentType, bootstrap: () => void) => {
|
271
|
+
// do something before bootstrap...
|
272
|
+
initSomething().then(() => {
|
273
|
+
bootstrap();
|
274
|
+
});
|
275
|
+
};
|
276
|
+
```
|
277
|
+
|
278
|
+
### Build Mode Entry
|
279
|
+
|
280
|
+
When an `index.[jt]sx` file exists in the entry directory and does not export a function via export default, this entry will also be considered a build mode entry.
|
@@ -55,7 +55,7 @@ It mainly includes the following features:
|
|
55
55
|
- 🏠 **Integration**: Development and production environment web server are unique, CSR and SSR are isomorphic development, and API service calls are functions as interfaces.
|
56
56
|
- 📦 **Out Of The Box**: Default TS support, built-in build, ESLint, debugging tools, fully functional and testable.
|
57
57
|
- 🌏 **Ecology**: Self-developed state management, micro-frontend, module packaging, and other peripheral needs.
|
58
|
-
- 🕸 **Routing
|
58
|
+
- 🕸 **Convention Routing**: Using file-based routing helps developers quickly set up applications.
|
59
59
|
|
60
60
|
## Comparison with Others
|
61
61
|
|
@@ -57,7 +57,7 @@ export default defineConfig({
|
|
57
57
|
ssr: true,
|
58
58
|
},
|
59
59
|
plugins: [appTools({
|
60
|
-
bundler: '
|
60
|
+
bundler: 'rspack', // Set to 'webpack' to enable webpack
|
61
61
|
}),],
|
62
62
|
});
|
63
63
|
```
|
@@ -72,7 +72,6 @@ In a newly created project, the `@modern-js/app-tools` npm package is installed
|
|
72
72
|
- It integrates Modern.js Core, providing capabilities for configuration parsing, plugin loading, and more.
|
73
73
|
- It integrates Modern.js Builder, providing build capabilities.
|
74
74
|
- It integrates Modern.js Server, providing capabilities for development and production servers.
|
75
|
-
- It integrates some commonly used plugins, such as `plugin-lint`, `plugin-data-loader`, and more.
|
76
75
|
|
77
76
|
`@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:
|
78
77
|
|
@@ -30,8 +30,6 @@ We are also working with Zack Jackson, the author of [Module Federation](https:/
|
|
30
30
|
|
31
31
|
Modern.js can be used with any community state management library, such as [Redux](https://redux.js.org/), [Jotai](https://jotai.org/), [Zustand](https://docs.pmnd.rs/zustand), [Valtio](https://valtio.pmnd.rs/), and more.
|
32
32
|
|
33
|
-
Modern.js also provides a wrapper around Redux called Reduck for state management. You can refer to ["Reduck State Management"](/en/guides/topic-detail/model/quick-start) for usage.
|
34
|
-
|
35
33
|
## Package Manager
|
36
34
|
|
37
35
|
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/).
|
@@ -62,7 +60,7 @@ During production builds, Modern.js uses [Terser](https://github.com/terser/ters
|
|
62
60
|
|
63
61
|
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.
|
64
62
|
|
65
|
-
Modern.js supports enabling ["Tailwind CSS"](/
|
63
|
+
Modern.js supports enabling ["Tailwind CSS"](/guides/basic-features/css/tailwindcss) and is compatible with both Tailwind CSS v2 and v3.
|
66
64
|
|
67
65
|
## CSS Preprocessors
|
68
66
|
|
@@ -75,11 +73,11 @@ Modern.js supports three CSS preprocessors: [Sass](https://sass-lang.com/), [Les
|
|
75
73
|
|
76
74
|
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).
|
77
75
|
|
78
|
-
Please refer to ["Use CSS Modules"](/guides/basic-features/css-modules) for usage instructions.
|
76
|
+
Please refer to ["Use CSS Modules"](/guides/basic-features/css/css-modules) for usage instructions.
|
79
77
|
|
80
78
|
## CSS-in-JS
|
81
79
|
|
82
|
-
Modern.js supports the use of [styled-components](https://styled-components.com/). Please refer to ["Using CSS-in-JS"](/en/guides/basic-features/css
|
80
|
+
Modern.js supports the use of [styled-components](https://styled-components.com/). Please refer to ["Using CSS-in-JS"](/en/guides/basic-features/css/css-in-js) for usage instructions.
|
83
81
|
|
84
82
|
If you need to use other CSS-in-JS solutions, you can integrate them into your project on your own.
|
85
83
|
|
@@ -91,7 +89,7 @@ Additionally, Modern.js provides built-in support for [on-demand import](/config
|
|
91
89
|
|
92
90
|
## Component Development
|
93
91
|
|
94
|
-
Modern.js supports the use of [Storybook](https://storybook.js.org/) for developing UI components. This feature is optional. Please refer to ["Using Storybook"](/
|
92
|
+
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) to enable it.
|
95
93
|
|
96
94
|
## Node.js Framework
|
97
95
|
|
@@ -37,10 +37,24 @@ import ReleaseNote from '@site-docs-en/components/release-note';
|
|
37
37
|
<ReleaseNote />
|
38
38
|
|
39
39
|
:::tip
|
40
|
-
When upgrading, you need to upgrade all packages provided by Modern.js,
|
41
|
-
|
40
|
+
When upgrading, you need to upgrade all packages provided by Modern.js, rather than upgrading some dependencies.
|
42
41
|
:::
|
43
42
|
|
43
|
+
## Version Management Strategy
|
44
|
+
|
45
|
+
In Modern.js projects, we recommend that all officially provided dependencies use fixed version, and avoid using `^` or `~` for range declarations. For example:
|
46
|
+
|
47
|
+
```json
|
48
|
+
{
|
49
|
+
"dependencies": {
|
50
|
+
"@modern-js/app-tools": "x.y.z"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
```
|
54
|
+
|
55
|
+
This ensures that the versions of dependencies are fully determined, thereby guaranteeing build consistency and predictability.
|
56
|
+
|
57
|
+
|
44
58
|
## Lock nested dependency
|
45
59
|
|
46
60
|
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.
|
@@ -40,16 +40,6 @@ import PackageManager from '@site-docs-en/components/package-manager';
|
|
40
40
|
|
41
41
|
<PackageManager />
|
42
42
|
|
43
|
-
### buildTools
|
44
|
-
|
45
|
-
Question: Please select the bundler.
|
46
|
-
|
47
|
-
Options:
|
48
|
-
|
49
|
-
- webpack -- webpack
|
50
|
-
|
51
|
-
- Rspack -- rspack
|
52
|
-
|
53
43
|
## Npm Module
|
54
44
|
|
55
45
|
### packageName
|
@@ -35,7 +35,6 @@ npx @modern-js/create@latest web-app
|
|
35
35
|
? Please select the type of project you want to create: Web App
|
36
36
|
? Please select the programming language: TS
|
37
37
|
? Please select the package manager: pnpm
|
38
|
-
? Please select the bundler: webpack
|
39
38
|
```
|
40
39
|
|
41
40
|
### Create an Npm Module Project
|
@@ -294,7 +294,7 @@ A Utility Class named `custom-text-gray` is implemented in `src/routes/styles/ut
|
|
294
294
|
```
|
295
295
|
|
296
296
|
:::info note
|
297
|
-
Modern.js integrates with [PostCSS](/guides/basic-features/css) and supports modern CSS syntax features such as [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties).
|
297
|
+
Modern.js integrates with [PostCSS](/guides/basic-features/css/css) and supports modern CSS syntax features such as [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties).
|
298
298
|
|
299
299
|
:::
|
300
300
|
|
@@ -52,7 +52,7 @@ function useLoader(loaderFn: LoaderFn, options: Options): ReturnData;
|
|
52
52
|
- `initialData`:首次执行前的初始数据,对应返回值中的 `data` 字段。
|
53
53
|
- `skip`:当值为 `true` 时,函数不执行。
|
54
54
|
- `params`:当 `params` 序列化结果发生改变时,函数会重新执行。同时,`params` 也会作为函数的第二个参数被传入。
|
55
|
-
- `static`:当值为 `true` 时,`useLoader` 用于 [SSG](/guides/
|
55
|
+
- `static`:当值为 `true` 时,`useLoader` 用于 [SSG](/guides/basic-features/render/ssg) 编译阶段数据的获取。
|
56
56
|
|
57
57
|
### 返回值
|
58
58
|
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
本地验证完成后,可以参考 [部署](/guides/basic-features/deploy.html) 一节,将项目部署到服务器上。
|