@modern-js/main-doc 2.54.5 → 2.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/docs/en/apis/app/hooks/src/entry.mdx +42 -0
  2. package/docs/en/apis/app/hooks/src/entry.server.mdx +52 -0
  3. package/docs/en/apis/app/hooks/src/index_.mdx +4 -0
  4. package/docs/en/apis/app/runtime/core/bootstrap.mdx +4 -0
  5. package/docs/en/apis/app/runtime/core/create-app.mdx +5 -1
  6. package/docs/en/apis/app/runtime/core/create-root.mdx +22 -0
  7. package/docs/en/apis/app/runtime/core/render.mdx +42 -0
  8. package/docs/en/apis/app/runtime/ssr/renderStreaming.mdx +69 -0
  9. package/docs/en/apis/app/runtime/ssr/renderString.mdx +62 -0
  10. package/docs/en/apis/app/runtime/ssr/requestHandler.mdx +47 -0
  11. package/docs/en/apis/app/runtime/web-server/middleware.mdx +3 -0
  12. package/docs/en/components/debug-app.mdx +3 -3
  13. package/docs/en/configure/app/output/ssg.mdx +4 -0
  14. package/docs/en/configure/app/source/enable-async-entry.mdx +4 -4
  15. package/docs/en/configure/app/source/enable-custom-entry.mdx +41 -0
  16. package/docs/en/guides/advanced-features/ssr/cache.mdx +7 -2
  17. package/docs/en/guides/concept/entries.mdx +50 -36
  18. package/docs/en/guides/get-started/quick-start.mdx +24 -8
  19. package/docs/en/guides/topic-detail/framework-plugin/hook-list.mdx +30 -177
  20. package/docs/zh/apis/app/hooks/src/entry.mdx +42 -0
  21. package/docs/zh/apis/app/hooks/src/entry.server.mdx +52 -0
  22. package/docs/zh/apis/app/hooks/src/index_.mdx +4 -0
  23. package/docs/zh/apis/app/runtime/core/bootstrap.mdx +4 -0
  24. package/docs/zh/apis/app/runtime/core/create-app.mdx +5 -1
  25. package/docs/zh/apis/app/runtime/core/create-root.mdx +22 -0
  26. package/docs/zh/apis/app/runtime/core/render.mdx +43 -0
  27. package/docs/zh/apis/app/runtime/ssr/renderStreaming.mdx +69 -0
  28. package/docs/zh/apis/app/runtime/ssr/renderString.mdx +62 -0
  29. package/docs/zh/apis/app/runtime/ssr/requestHandler.mdx +47 -0
  30. package/docs/zh/apis/app/runtime/web-server/middleware.mdx +4 -0
  31. package/docs/zh/components/debug-app.mdx +3 -2
  32. package/docs/zh/configure/app/dev/client.mdx +1 -1
  33. package/docs/zh/configure/app/output/ssg.mdx +4 -0
  34. package/docs/zh/configure/app/source/enable-async-entry.mdx +4 -4
  35. package/docs/zh/configure/app/source/enable-custom-entry.mdx +41 -0
  36. package/docs/zh/guides/advanced-features/ssr/cache.mdx +6 -2
  37. package/docs/zh/guides/concept/entries.mdx +54 -41
  38. package/docs/zh/guides/get-started/quick-start.mdx +26 -10
  39. package/docs/zh/guides/topic-detail/framework-plugin/hook-list.mdx +29 -174
  40. package/package.json +5 -5
  41. package/docs/en/apis/app/hooks/src/pages.mdx +0 -186
  42. package/docs/zh/apis/app/hooks/src/pages.mdx +0 -187
  43. package/docs/zh/apis/monorepo/commands/deploy.mdx +0 -38
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: entry.[tj]s
3
+ sidebar_position: 4
4
+ ---
5
+ # entry.[tj]s
6
+
7
+ :::info
8
+ Using this file requires enabling [source.enableCustomEntry](/configure/app/source/enable-custom-entry).
9
+ :::
10
+
11
+ Normally, the [`routes/`](/apis/app/hooks/src/routes.html) and [`App.[tj]sx`](/apis/app/hooks/src/app) hook files can meet our needs. When we need to add custom behavior before component rendering or take full control of the webpack packaging entry, we can create `entry.[tj]s` file in the src or entry directory. Here are two cases for discussion:
12
+
13
+ ## Add custom behavior before Render
14
+
15
+ This is implemented in `src/entry.[tj]s` as follows:
16
+
17
+ ```js title=src/entry.tsx
18
+ import { createRoot } from '@modern-js/runtime/react';
19
+ import { render } from '@modern-js/runtime/browser';
20
+
21
+ const ModernRoot = createRoot();
22
+
23
+ async function beforeRender() {
24
+ // todo
25
+ }
26
+
27
+ beforeRender().then(() => {
28
+ render(<ModernRoot />);
29
+ });
30
+ ```
31
+
32
+ ## Take full control of the webpack entry
33
+
34
+ When the project does not install the `@modern-js/runtime` dependency, `src/entry.[tj]sx?` is the real webpack packaging entry file, and you can directly organize the code like using create-react-app and other scaffolds:
35
+
36
+ ```js title=src/entry.jsx
37
+ import React from 'react';
38
+ import ReactDOM from 'react-dom/client';
39
+ import App from './App';
40
+
41
+ ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
42
+ ```
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: entry.server.[tj]sx
3
+ sidebar_position: 5
4
+ ---
5
+
6
+ # entry.server.[tj]sx
7
+
8
+ When the project initiates `server.ssr`, Modern.js generates a default Server-Side entry. The sample code is as follows:
9
+
10
+ ```tsx title="entry.server.tsx"
11
+ import {
12
+ renderString,
13
+ createRequestHandler,
14
+ } from '@modern-js/runtime/ssr/server';
15
+
16
+ const handleRequest = async (request, ServerRoot, options) => {
17
+ const body = await renderString(request, <ServerRoot />, options);
18
+
19
+ return new Response(body, {
20
+ headers: {
21
+ 'content-type': 'text/html; charset=utf-8',
22
+ },
23
+ });
24
+ };
25
+
26
+ export default createRequestHandler(handleRequest);
27
+ ```
28
+
29
+ ## Add Custom Entry Points
30
+
31
+ Users need to customize the Server-Side Rendering entry points, they can customize the server entry in `src/entry.server.ts` or `src/{entryName}/entry.server.ts`.
32
+
33
+ ```tsx title="src/entry.server.tsx"
34
+ import { renderString, createRequestHandler } from '@edenx/runtime/ssr/server';
35
+ import type { HandleRequest } from '@edenx/runtime/ssr/server';
36
+
37
+ const handleRequest: HandleRequest = async (request, ServerRoot, options) => {
38
+ // do something before rendering
39
+ const body = await renderString(request, <ServerRoot />, options);
40
+
41
+ const newBody = body + '<div>Byte-Dance</div>';
42
+
43
+ return new Response(newBody, {
44
+ headers: {
45
+ 'content-type': 'text/html; charset=UTF-8',
46
+ 'x-custom-header': 'abc',
47
+ },
48
+ });
49
+ };
50
+
51
+ export default createRequestHandler(handleRequest);
52
+ ```
@@ -4,6 +4,10 @@ sidebar_position: 4
4
4
  ---
5
5
  # index.[tj]s
6
6
 
7
+ :::warning
8
+ Soon to be deprecated, it is recommended to use [`entry.[tj]s`](/apis/app/hooks/src/entry)。
9
+ :::
10
+
7
11
  The identifier for the entry point when the application uses custom `bootstrap`.
8
12
 
9
13
  In general, the [`App.[tj]sx`](/apis/app/hooks/src/app) hook file can already meet our needs. When we need to add custom behavior before `bootstrap` or completely take over the webpack packaging entry, we can place `index.[tj]s` in the `src` or entry directory. There are two cases below:
@@ -3,6 +3,10 @@ title: bootstrap
3
3
  ---
4
4
  # bootstrap
5
5
 
6
+ :::warning
7
+ Soon to be deprecated, it is recommended to use [`render`](/apis/app/runtime/core/render).
8
+ :::
9
+
6
10
  Used to start and mount App, usually not manually called. This API is only required when using [Custom Bootstrap](/guides/concept/entries#custom-bootstrap).
7
11
 
8
12
  ## Usage
@@ -3,7 +3,11 @@ title: createApp
3
3
  ---
4
4
  # createApp
5
5
 
6
- Used to create custom entries, custom runtime plugins. This API is only required when using [Custom App](/guides/concept/entries#app).
6
+ :::warning
7
+ Soon to be deprecated, it is recommended to use [`createRoot`](/apis/app/runtime/core/create-root).
8
+ :::
9
+
10
+ Used for creating custom entries and customizing runtime plugins.
7
11
 
8
12
  ## Usage
9
13
 
@@ -0,0 +1,22 @@
1
+ ---
2
+ title: createRoot
3
+ ---
4
+ # createRoot
5
+
6
+ It is used to create the root component provided by Modern.js, which will automatically register Runtime plugins and complete the initialization of Runtime plugins.
7
+
8
+ ## Usage
9
+
10
+ ```ts
11
+ import { createRoot } from '@modern-js/runtime/react';
12
+ ```
13
+
14
+ ## Function Signature
15
+
16
+ ```ts
17
+ export function createRoot(UserApp?: React.ComponentType | null): React.ComponentType<any>;
18
+ ```
19
+
20
+ ### Parameters
21
+
22
+ - `UserApp`: an optional parameter, and the default is the component exported from `App.tsx`.
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: render
3
+ ---
4
+ # render
5
+
6
+ It is used to render project components.
7
+
8
+ ## Usage
9
+
10
+ ```ts
11
+ import { render } from '@modern-js/runtime/browser';
12
+
13
+ render(<ModernRoot />);
14
+ ```
15
+
16
+ ## Function Signature
17
+
18
+ ```ts
19
+ export function render(App: React.ReactElement, id?: HTMLElement | string): Promise<any>;
20
+ ```
21
+
22
+ ### Parameters
23
+
24
+ - `App`:An instance of ReactElement created through [`createRoot`](./create-root).
25
+ - `id`:The id of the DOM root element to be mounted, such as "root".
26
+
27
+ ## Example
28
+
29
+ ```tsx
30
+ import { createRoot } from '@modern-js/runtime/react';
31
+ import { render } from '@modern-js/runtime/browser';
32
+
33
+ const ModernRoot = createRoot();
34
+
35
+ async function beforeRender() {
36
+ // todo
37
+ }
38
+
39
+ beforeRender().then(() => {
40
+ render(<ModernRoot />);
41
+ });
42
+ ```
@@ -0,0 +1,69 @@
1
+ ---
2
+ title: renderStreaming
3
+ ---
4
+
5
+ # renderStreaming
6
+
7
+ Used for React v18+ Streaming SSR to render readable streams, used in conjunction with `createRequestHandler`.
8
+
9
+ ## Usage
10
+
11
+ ```ts title="src/entry.server.tsx"
12
+ import {
13
+ renderStreaming,
14
+ createRequestHandler,
15
+ } from '@modern-js/runtime/ssr/server';
16
+
17
+ const handleRequest = async (request, ServerRoot, options) => {
18
+ const stream = await renderStreaming(request, <ServerRoot />, options);
19
+
20
+ return new Response(stream, {
21
+ headers: {
22
+ 'content-type': 'text/html; charset=utf-8',
23
+ },
24
+ });
25
+ };
26
+
27
+ export default createRequestHandler(handleRequest);
28
+ ```
29
+
30
+ ## Function Signature
31
+
32
+ ```ts
33
+ export type RenderStreaming = (
34
+ request: Request,
35
+ serverRoot: React.ReactElement,
36
+ optinos: RenderOptions,
37
+ ) => Promise<ReadableStream>;
38
+ ```
39
+
40
+ ## Example
41
+
42
+ ```tsx title="src/entry.server.tsx"
43
+ import {
44
+ renderStreaming,
45
+ createRequestHandler,
46
+ } from '@modern-js/runtime/ssr/server';
47
+
48
+ const handleRequest = async (request, ServerRoot, options) => {
49
+ // do something before render
50
+ const stream = await renderStreaming(request, <ServerRoot />, options);
51
+
52
+ // docs: https://developer.mozilla.org/en-US/docs/Web/API/TransformStream
53
+ const transformStream = new TransformStream({
54
+ transform(chunk, controller) {
55
+ // do some transform
56
+ },
57
+ });
58
+
59
+ stream.pipeThrough(transformStream);
60
+
61
+ return new Response(transformStream.readable, {
62
+ headers: {
63
+ 'content-type': 'text/html; charset=utf-8',
64
+ },
65
+ });
66
+ };
67
+
68
+ export default createRequestHandler(handleRequest);
69
+ ```
@@ -0,0 +1,62 @@
1
+ ---
2
+ title: renderString
3
+ ---
4
+
5
+ # renderString
6
+
7
+ Used for React String SSR to render strings, used in conjunction with `createRequestHandler`.
8
+
9
+ ## Usage
10
+
11
+ ```tsx title="src/entry.server.tsx"
12
+ import {
13
+ renderString,
14
+ createRequestHandler,
15
+ } from '@modern-js/runtime/ssr/server';
16
+
17
+ const handleRequest = async (request, ServerRoot, options) => {
18
+ const body = await renderString(request, <ServerRoot />, options);
19
+
20
+ return new Response(body, {
21
+ headers: {
22
+ 'content-type': 'text/html; charset=utf-8',
23
+ },
24
+ });
25
+ };
26
+
27
+ export default createRequestHandler(handleRequest);
28
+ ```
29
+
30
+ ## Function Signature
31
+
32
+ ```ts
33
+ export type RenderString = (
34
+ request: Request,
35
+ serverRoot: React.ReactElement,
36
+ optinos: RenderOptions,
37
+ ) => Promise<string>;
38
+ ```
39
+
40
+ ## Example
41
+
42
+ ```tsx title="src/entry.server.tsx"
43
+ import {
44
+ renderString,
45
+ createRequestHandler,
46
+ } from '@modern-js/runtime/ssr/server';
47
+
48
+ const handleRequest = async (request, ServerRoot, options) => {
49
+ // do something before render
50
+ const body = await renderString(request, <ServerRoot />, options);
51
+
52
+ const newBody = body + '<div>Byte-Dance</div>';
53
+
54
+ return new Response(newBody, {
55
+ headers: {
56
+ 'content-type': 'text/html; charset=utf-8',
57
+ },
58
+ });
59
+ };
60
+
61
+ export default createRequestHandler(handleRequest);
62
+ ```
@@ -0,0 +1,47 @@
1
+ ---
2
+ title: createRequestHandler
3
+ ---
4
+
5
+ # createRequestHandler
6
+
7
+ Used to customize the Server-Side Rendering entry to return the `requestHandler`.
8
+
9
+ ## Usage
10
+
11
+ ```tsx title="src/entry.server.tsx"
12
+ import {
13
+ renderString,
14
+ createRequestHandler,
15
+ } from '@modern-js/runtime/ssr/server';
16
+
17
+ const handleRequest = async (request, ServerRoot, options) => {
18
+ const body = await renderString(request, <ServerRoot />, options);
19
+
20
+ return new Response(body, {
21
+ headers: {
22
+ 'content-type': 'text/html; charset=utf-8',
23
+ },
24
+ });
25
+ };
26
+
27
+ export default createRequestHandler(handleRequest);
28
+ ```
29
+
30
+ ## Function Signature
31
+
32
+ ```ts
33
+ export type HandleRequest = (
34
+ request: Request,
35
+ ServerRoot: React.ComponentType,
36
+ options: HandleRequestOptions,
37
+ ) => Promise<Response>;
38
+
39
+ export type RequestHandler = (
40
+ request: Request,
41
+ options: RequestHandlerOptions,
42
+ ) => Promise<Response>;
43
+
44
+ export type CreateRequestHandler = (
45
+ handleRequest: HandleRequest,
46
+ ) => Promise<RequestHandler>;
47
+ ```
@@ -7,12 +7,15 @@ title: Middleware
7
7
  Used to extend the built-in Web Server of Modern.js, unlike [Hook](/apis/app/runtime/web-server/hook), Middleware can directly operate Node's origin request and response, and can be extended using the framework plugin.
8
8
 
9
9
  :::note
10
+
10
11
  In the next major release, Modern.js will use new middleware to replace this approach.
11
12
 
12
13
  It is recommended to use [UnstableMiddleware](/apis/app/runtime/web-server/unstable_middleware) to handle page requests.
14
+
13
15
  :::
14
16
 
15
17
  :::note
18
+
16
19
  For more detail, see [Extend Web Server](/guides/advanced-features/web-server).
17
20
 
18
21
  :::
@@ -2,11 +2,11 @@ Run `pnpm run dev` in the project to start the project:
2
2
 
3
3
  ```bash
4
4
  $ pnpm run dev
5
-
6
5
  > modern dev
7
6
 
8
- info Starting dev server...
9
- ready Client compiled in 50 ms
7
+ Modern.js Framework v2.55.0
8
+
9
+ ready Client compiled in 0.86 s
10
10
 
11
11
  > Local: http://localhost:8080/
12
12
  > Network: http://192.168.0.1:8080/
@@ -9,6 +9,10 @@ sidebar_label: ssg
9
9
 
10
10
  Enable the SSG for **Self-controlled Routing** or **Conventional Routing**.
11
11
 
12
+ :::info Enable SSG
13
+ This configuration will only be available when the SSG feature is enabled. Please read the [Static Site Generation](/guides/advanced-features/ssg) documentation to learn how to enable the SSG feature.
14
+ :::
15
+
12
16
  :::info
13
17
  For more routes detail, see [Routing](/guides/basic-features/routes).
14
18
 
@@ -35,15 +35,15 @@ Then run the `dev` or `build` command, and you will see that the files automatic
35
35
  node_modules
36
36
  └─ .modern-js
37
37
  └─ main
38
- ├─ bootstrap.jsx # real entry code
39
- ├─ index.js # asynchronous entry file
38
+ ├─ bootstrap.jsx # asynchronous entry file
39
+ ├─ index.js # real entry code
40
40
  └─ index.html
41
41
  ```
42
42
 
43
- The contents of `index.js` are as follows:
43
+ The contents of `bootstrap.js` are as follows:
44
44
 
45
45
  ```js
46
- import('./bootstrap.jsx');
46
+ import('./index.jsx');
47
47
  ```
48
48
 
49
49
  At this point, you can consume any remote module in the current page.
@@ -0,0 +1,41 @@
1
+ ---
2
+ sidebar_label: enableCustomEntry
3
+ ---
4
+
5
+ # source.enableCustomEntry
6
+
7
+ - **Type:** `boolean`
8
+ - **Default:** `false`
9
+
10
+ This option is used for custom Modern.js entries.
11
+
12
+ When this option is enabled, Modern.js will use the `src/entry.[jt]sx` file as the project's entry point. For more details, refer to [Entries](/guides/concept/entries.html).
13
+
14
+ ## Example
15
+
16
+ First, enable this option in the configuration file:
17
+
18
+ ```ts title="modern.config.ts"
19
+ export default defineConfig({
20
+ source: {
21
+ enableCustomEntry: true,
22
+ },
23
+ });
24
+ ```
25
+
26
+ Create the `src/entry.tsx` file:
27
+
28
+ ```tsx
29
+ import { createRoot } from '@modern-js/runtime/react';
30
+ import { render } from '@modern-js/runtime/browser';
31
+
32
+ const ModernRoot = createRoot();
33
+
34
+ async function beforeRender() {
35
+ // todo
36
+ }
37
+
38
+ beforeRender().then(() => {
39
+ render(<ModernRoot />);
40
+ });
41
+ ```
@@ -53,10 +53,10 @@ In this, customKey is used for custom cache key. By default, Modern.js will use
53
53
  ```ts
54
54
  export type CacheOptionProvider = (
55
55
  req: IncomingMessage,
56
- ) => Promise<CacheControl> | CacheControl;
56
+ ) => Promise<CacheControl | false> | CacheControl | false;
57
57
  ```
58
58
 
59
- Sometimes developers need to customise the cache key through req, which can be handled using the function form, as shown in the following code:
59
+ Sometimes developers need to customise the cache key through req or when caching does not work for specific URLs, which can be handled using the function form, as shown in the following code:
60
60
 
61
61
  ```ts title="server/cache.ts"
62
62
  import type { CacheOption, CacheOptionProvider } from '@modern-js/runtime/server';
@@ -66,6 +66,11 @@ const provider: CacheOptionProvider = (req) => {
66
66
 
67
67
  const key = computedKey(url, headers, ...);
68
68
 
69
+ if(url.includes('no-cache=1')) {
70
+ return false;
71
+ }
72
+
73
+
69
74
  return {
70
75
  maxAge: 500, // ms
71
76
  staleWhileRevalidate: 1000, // ms
@@ -82,12 +82,13 @@ By default, Modern.js scans the files under `src/` before starting the project,
82
82
 
83
83
  :::
84
84
 
85
- Not all top-level directories under `src/` become project entries. The directory where the entry is located must meet one of the following four conditions:
85
+ Not all top-level directories under `src/` become project entries. The directory where the entry is located must meet one of the following five conditions:
86
86
 
87
87
  1. Has a `routes/` directory.
88
88
  2. Has an `App.[jt]sx?` file.
89
89
  3. Has an `index.[jt]sx?` file.
90
90
  4. Has a `pages/` directory (compatible with Modern.js 1.0).
91
+ 5. Has an `entry.[jt]sx?` file.
91
92
 
92
93
  When the `src/` directory meets the entry requirements, Modern.js considers the current project as a single entry application.
93
94
 
@@ -139,8 +140,46 @@ export default () => {
139
140
 
140
141
  For more information, please refer to [Self-controlled Routing](/guides/basic-features/routes.html#self-controlled-routing).
141
142
 
143
+ #### Custom Entry
144
+
145
+ If there is an `entry.[jt]sx` file in the entry, developers need to call the `createRoot` and `render` functions in the `entry.[jt]sx` file to complete the project's entry logic.
146
+
147
+ :::info
148
+ Using this file requires enabling [source.enableCustomEntry](/configure/app/source/enable-custom-entry).
149
+ :::
150
+
151
+ ```tsx
152
+ import { createRoot } from '@modern-js/runtime/react';
153
+ import { render } from '@modern-js/runtime/browser';
154
+
155
+ const ModernRoot = createRoot();
156
+
157
+ render(<ModernRoot />);
158
+ ```
159
+
160
+ For example, if some other operations need to be performed before render is executed, it can be implemented in this way:
161
+
162
+ ```tsx
163
+ import { createRoot } from '@modern-js/runtime/react';
164
+ import { render } from '@modern-js/runtime/browser';
165
+
166
+ const ModernRoot = createRoot();
167
+
168
+ async function beforeRender() {
169
+ // todo
170
+ }
171
+
172
+ beforeRender().then(() => {
173
+ render(<ModernRoot />);
174
+ });
175
+ ```
176
+
142
177
  #### Custom Bootstrap
143
178
 
179
+ :::warning
180
+ Soon to be deprecated, it is recommended to use a custom entry.
181
+ :::
182
+
144
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:
145
184
 
146
185
  ```tsx
@@ -152,44 +191,19 @@ export default (App: React.ComponentType, bootstrap: () => void) => {
152
191
  };
153
192
  ```
154
193
 
155
- At this point, the generated file content of Modern.js is as follows:
156
-
157
- ```js
158
- import React from 'react';
159
- import ReactDOM from 'react-dom/client';
160
- import customBootstrap from '@_modern_js_src/index.tsx';
161
- import App from '@_modern_js_src/App';
162
- import { router, state } from '@modern-js/runtime/plugins';
163
-
164
- const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
165
- const MOUNT_ID = 'root';
166
-
167
- let AppWrapper = null;
168
-
169
- function render() {
170
- AppWrapper = createApp({
171
- // plugin parameters for runtime...
172
- })(App);
173
- if (IS_BROWSER) {
174
- customBootstrap(AppWrapper);
175
- }
176
- return AppWrapper;
177
- }
178
-
179
- AppWrapper = render();
180
-
181
- export default AppWrapper;
182
- ```
183
-
184
194
  ### Build Mode Entry
185
195
 
186
- Build mode refers to the mode where the entry point of the page is not automatically generated by Modern.js, but is fully defined by the developers themselves.
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.
187
199
 
188
- When there is an `index.[jt]sx` file in the entry directory and it is not exported as a function using `export default`, this type of file will be recognized as the entry module for webpack or Rspack.
200
+ :::info
201
+ Using the `entry.[jt]sx` file requires enabling [source.enableCustomEntry](/configure/app/source/enable-custom-entry).
202
+ :::
189
203
 
190
204
  In this case, Modern.js will not generate the entry code automatically. Therefore, you need to manually mount the component to the DOM node, for example:
191
205
 
192
- ```js title=src/index.jsx
206
+ ```js title=src/entry.tsx
193
207
  import React from 'react';
194
208
  import ReactDOM from 'react-dom';
195
209
  import App from './App';
@@ -197,9 +211,9 @@ import App from './App';
197
211
  ReactDOM.render(<App />, document.getElementById('root'));
198
212
  ```
199
213
 
200
- This approach is equivalent to enabling the [source.entries.disableMount](/configure/app/source/entries) option in Modern.js. When you use this approach, **you will not be able to use the runtime capabilities of the Modern.js framework**, such as the `runtime` configuration in the modern.config.js file will no longer take effect.
214
+ This approach is equivalent to enabling the [source.entries.disableMount](/configure/app/source/entries) option in Modern.js. When you use this approach, **you will not be able to use the runtime capabilities of the Modern.js framework**, such as the `runtime` configuration in the `modern.config.js` file will no longer take effect.
201
215
 
202
- ## Custom Entries
216
+ ## Custom Entries Config
203
217
 
204
218
  In some cases, you may need to customize the entry configuration instead of using the entry conventions provided by Modern.js.
205
219
 
@@ -232,4 +246,4 @@ export default defineConfig({
232
246
  });
233
247
  ```
234
248
 
235
- Note that when you enable `disableMount`, **you won't be able to use the runtime capabilities of the Modern.js framework**, such as the `runtime` configuration in the modern.config.ts file.
249
+ Note that when you enable `disableMount`, **you won't be able to use the runtime capabilities of the Modern.js framework**, such as the `runtime` configuration in the `modern.config.ts` file.