@modern-js/runtime 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/document/Html.js +16 -4
- package/dist/cjs/router/cli/code/utils.js +6 -1
- package/dist/esm/cli/code.mjs +12 -12
- package/dist/esm/document/Html.mjs +16 -4
- package/dist/esm/exports/loadable.mjs +1 -1
- package/dist/esm/router/cli/code/index.mjs +5 -5
- package/dist/esm/router/cli/code/nestedRoutes.mjs +7 -7
- package/dist/esm/router/cli/code/utils.mjs +6 -1
- package/dist/esm/router/cli/handler.mjs +3 -3
- package/dist/esm/router/runtime/index.mjs +1 -1
- package/dist/esm-node/cli/code.mjs +12 -12
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +2 -2
- package/dist/esm-node/core/server/string/loadable.mjs +2 -2
- package/dist/esm-node/document/Html.mjs +16 -4
- package/dist/esm-node/exports/loadable.mjs +1 -1
- package/dist/esm-node/router/cli/code/index.mjs +5 -5
- package/dist/esm-node/router/cli/code/nestedRoutes.mjs +7 -7
- package/dist/esm-node/router/cli/code/utils.mjs +6 -1
- package/dist/esm-node/router/cli/handler.mjs +3 -3
- package/dist/esm-node/router/cli/index.mjs +2 -2
- package/dist/esm-node/router/runtime/index.mjs +1 -1
- package/package.json +12 -12
|
@@ -31,12 +31,24 @@ require("react");
|
|
|
31
31
|
const external_Body_js_namespaceObject = require("./Body.js");
|
|
32
32
|
const external_DocumentStructureContext_js_namespaceObject = require("./DocumentStructureContext.js");
|
|
33
33
|
const external_Head_js_namespaceObject = require("./Head.js");
|
|
34
|
+
const external_Links_js_namespaceObject = require("./Links.js");
|
|
35
|
+
const external_Root_js_namespaceObject = require("./Root.js");
|
|
36
|
+
const external_Scripts_js_namespaceObject = require("./Scripts.js");
|
|
34
37
|
function findTargetChildByName(tag, children) {
|
|
35
38
|
return children.find((item)=>getEleType(item) === tag);
|
|
36
39
|
}
|
|
37
40
|
function findTargetChildByComponent(component, children) {
|
|
38
41
|
return children.find((item)=>item?.type === component);
|
|
39
42
|
}
|
|
43
|
+
function findTargetElementByComponent(component, children) {
|
|
44
|
+
if (0 === children.length) return null;
|
|
45
|
+
let nextChildren = [];
|
|
46
|
+
for (const item of children){
|
|
47
|
+
if (item?.type === component) return item;
|
|
48
|
+
if (item?.props?.children) nextChildren = nextChildren.concat(item.props.children);
|
|
49
|
+
}
|
|
50
|
+
return findTargetElementByComponent(component, nextChildren);
|
|
51
|
+
}
|
|
40
52
|
function getEleType(ele) {
|
|
41
53
|
return 'function' == typeof ele?.type ? ele.type.name : ele?.type;
|
|
42
54
|
}
|
|
@@ -52,10 +64,10 @@ function findTargetElement(tag, children) {
|
|
|
52
64
|
function Html(props) {
|
|
53
65
|
const { children, ...rest } = props;
|
|
54
66
|
const hasSetHead = Boolean(findTargetChildByComponent(external_Head_js_namespaceObject.Head, children) || findTargetChildByName('Head', children));
|
|
55
|
-
const hasSetScripts = Boolean(
|
|
56
|
-
const hasSetLinks = Boolean(
|
|
57
|
-
const hasSetBody = Boolean(
|
|
58
|
-
const hasSetRoot = Boolean(
|
|
67
|
+
const hasSetScripts = Boolean(findTargetElementByComponent(external_Scripts_js_namespaceObject.Scripts, children) || findTargetChildByName('Scripts', children));
|
|
68
|
+
const hasSetLinks = Boolean(findTargetElementByComponent(external_Links_js_namespaceObject.Links, children) || findTargetChildByName('Links', children));
|
|
69
|
+
const hasSetBody = Boolean(findTargetElementByComponent(external_Body_js_namespaceObject.Body, children) || findTargetChildByName('Body', children));
|
|
70
|
+
const hasSetRoot = Boolean(findTargetElementByComponent(external_Root_js_namespaceObject.Root, children) || findTargetChildByName('Root', children));
|
|
59
71
|
const hasSetTitle = Boolean(findTargetElement('title', children));
|
|
60
72
|
const notMissMustChild = [
|
|
61
73
|
hasSetHead,
|
|
@@ -81,7 +81,12 @@ const parseModule = async ({ source, filename })=>{
|
|
|
81
81
|
if (utils_namespaceObject.JS_EXTENSIONS.some((ext)=>filename.endsWith(ext))) {
|
|
82
82
|
const result = await (0, external_esbuild_namespaceObject.transform)(content, {
|
|
83
83
|
loader: external_path_default().extname(filename).slice(1),
|
|
84
|
-
format: 'esm'
|
|
84
|
+
format: 'esm',
|
|
85
|
+
tsconfigRaw: {
|
|
86
|
+
compilerOptions: {
|
|
87
|
+
experimentalDecorators: true
|
|
88
|
+
}
|
|
89
|
+
}
|
|
85
90
|
});
|
|
86
91
|
content = result.code;
|
|
87
92
|
}
|
package/dist/esm/cli/code.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import path from "path";
|
|
|
2
2
|
import { fs } from "@modern-js/utils";
|
|
3
3
|
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_POINT_REGISTER_FILE_NAME, ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME, ENTRY_POINT_RUNTIME_REGISTER_FILE_NAME, ENTRY_SERVER_BOOTSTRAP_FILE_NAME, INDEX_FILE_NAME, SERVER_ENTRY_POINT_FILE_NAME } from "./constants.mjs";
|
|
4
4
|
import { resolveSSRMode } from "./ssr/mode.mjs";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as __rspack_external__template_mjs_d6ab8956 from "./template.mjs";
|
|
6
|
+
import * as __rspack_external__template_server_mjs_38d6edb1 from "./template.server.mjs";
|
|
7
7
|
const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
8
8
|
const { mountId } = config.html;
|
|
9
9
|
const { enableAsyncEntry } = config.source;
|
|
@@ -21,7 +21,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
21
21
|
nestedRoutesEntry
|
|
22
22
|
});
|
|
23
23
|
let indexCode = '';
|
|
24
|
-
indexCode = ssrMode || !config.server.rsc || customEntry ? index({
|
|
24
|
+
indexCode = ssrMode || !config.server.rsc || customEntry ? __rspack_external__template_mjs_d6ab8956.index({
|
|
25
25
|
srcDirectory,
|
|
26
26
|
internalSrcAlias,
|
|
27
27
|
metaName,
|
|
@@ -31,7 +31,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
31
31
|
mountId,
|
|
32
32
|
enableRsc: config.server.rsc,
|
|
33
33
|
isNestedRouter: !!entrypoint.nestedRoutesEntry
|
|
34
|
-
}) : entryForCSRWithRSC({
|
|
34
|
+
}) : __rspack_external__template_mjs_d6ab8956.entryForCSRWithRSC({
|
|
35
35
|
metaName,
|
|
36
36
|
entryName,
|
|
37
37
|
mountId,
|
|
@@ -47,7 +47,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
47
47
|
if (ssrMode) await fs.outputFile(bootstrapServerFile, `export const requestHandler = import('./${SERVER_ENTRY_POINT_FILE_NAME}').then((m) => m.requestHandler)`, 'utf8');
|
|
48
48
|
}
|
|
49
49
|
if (ssrMode) {
|
|
50
|
-
const indexServerCode = serverIndex({
|
|
50
|
+
const indexServerCode = __rspack_external__template_server_mjs_38d6edb1.serverIndex({
|
|
51
51
|
entry,
|
|
52
52
|
entryName,
|
|
53
53
|
internalSrcAlias,
|
|
@@ -61,16 +61,16 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
61
61
|
await fs.outputFile(indexServerFile, indexServerCode, 'utf8');
|
|
62
62
|
} else if (config.server.rsc) {
|
|
63
63
|
const indexServerFile = path.resolve(internalDirectory, `./${entryName}/${SERVER_ENTRY_POINT_FILE_NAME}`);
|
|
64
|
-
const indexServerCode =
|
|
64
|
+
const indexServerCode = __rspack_external__template_server_mjs_38d6edb1.entryForCSRWithRSC({
|
|
65
65
|
entryName,
|
|
66
66
|
metaName
|
|
67
67
|
});
|
|
68
68
|
await fs.outputFile(indexServerFile, indexServerCode, 'utf8');
|
|
69
69
|
}
|
|
70
|
-
const registerCode = register();
|
|
70
|
+
const registerCode = __rspack_external__template_mjs_d6ab8956.register();
|
|
71
71
|
const registerFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_REGISTER_FILE_NAME}`);
|
|
72
72
|
await fs.outputFile(registerFile, registerCode, 'utf8');
|
|
73
|
-
const registerRuntimeCode = runtimeRegister({
|
|
73
|
+
const registerRuntimeCode = __rspack_external__template_mjs_d6ab8956.runtimeRegister({
|
|
74
74
|
entryName,
|
|
75
75
|
srcDirectory,
|
|
76
76
|
internalSrcAlias,
|
|
@@ -84,7 +84,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
84
84
|
if (!config.server.rsc || entrypoint.nestedRoutesEntry) {
|
|
85
85
|
const route = serverRoutes.find((r)=>r.entryName === entryName);
|
|
86
86
|
const basename = route?.urlPath || '/';
|
|
87
|
-
contextCode = runtimeGlobalContext({
|
|
87
|
+
contextCode = __rspack_external__template_mjs_d6ab8956.runtimeGlobalContext({
|
|
88
88
|
entryName,
|
|
89
89
|
srcDirectory,
|
|
90
90
|
internalSrcAlias,
|
|
@@ -95,18 +95,18 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
95
95
|
});
|
|
96
96
|
} else {
|
|
97
97
|
const AppProxyPath = path.join(internalDirectory, entryName, './AppProxy.jsx');
|
|
98
|
-
const appProxyCode = AppProxyForRSC({
|
|
98
|
+
const appProxyCode = __rspack_external__template_mjs_d6ab8956.AppProxyForRSC({
|
|
99
99
|
srcDirectory,
|
|
100
100
|
internalSrcAlias,
|
|
101
101
|
entry,
|
|
102
102
|
customEntry
|
|
103
103
|
});
|
|
104
104
|
await fs.outputFile(AppProxyPath, appProxyCode);
|
|
105
|
-
contextCode = runtimeGlobalContextForRSCClient({
|
|
105
|
+
contextCode = __rspack_external__template_mjs_d6ab8956.runtimeGlobalContextForRSCClient({
|
|
106
106
|
metaName,
|
|
107
107
|
customEntry
|
|
108
108
|
});
|
|
109
|
-
const contextServerCode = runtimeGlobalContextForRSCServer({
|
|
109
|
+
const contextServerCode = __rspack_external__template_mjs_d6ab8956.runtimeGlobalContextForRSCServer({
|
|
110
110
|
metaName
|
|
111
111
|
});
|
|
112
112
|
const contextFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}.server.js`);
|
|
@@ -3,12 +3,24 @@ import "react";
|
|
|
3
3
|
import { Body } from "./Body.mjs";
|
|
4
4
|
import { DocumentStructureContext } from "./DocumentStructureContext.mjs";
|
|
5
5
|
import { Head } from "./Head.mjs";
|
|
6
|
+
import { Links } from "./Links.mjs";
|
|
7
|
+
import { Root } from "./Root.mjs";
|
|
8
|
+
import { Scripts } from "./Scripts.mjs";
|
|
6
9
|
function findTargetChildByName(tag, children) {
|
|
7
10
|
return children.find((item)=>getEleType(item) === tag);
|
|
8
11
|
}
|
|
9
12
|
function findTargetChildByComponent(component, children) {
|
|
10
13
|
return children.find((item)=>item?.type === component);
|
|
11
14
|
}
|
|
15
|
+
function findTargetElementByComponent(component, children) {
|
|
16
|
+
if (0 === children.length) return null;
|
|
17
|
+
let nextChildren = [];
|
|
18
|
+
for (const item of children){
|
|
19
|
+
if (item?.type === component) return item;
|
|
20
|
+
if (item?.props?.children) nextChildren = nextChildren.concat(item.props.children);
|
|
21
|
+
}
|
|
22
|
+
return findTargetElementByComponent(component, nextChildren);
|
|
23
|
+
}
|
|
12
24
|
function getEleType(ele) {
|
|
13
25
|
return 'function' == typeof ele?.type ? ele.type.name : ele?.type;
|
|
14
26
|
}
|
|
@@ -24,10 +36,10 @@ function findTargetElement(tag, children) {
|
|
|
24
36
|
function Html(props) {
|
|
25
37
|
const { children, ...rest } = props;
|
|
26
38
|
const hasSetHead = Boolean(findTargetChildByComponent(Head, children) || findTargetChildByName('Head', children));
|
|
27
|
-
const hasSetScripts = Boolean(
|
|
28
|
-
const hasSetLinks = Boolean(
|
|
29
|
-
const hasSetBody = Boolean(
|
|
30
|
-
const hasSetRoot = Boolean(
|
|
39
|
+
const hasSetScripts = Boolean(findTargetElementByComponent(Scripts, children) || findTargetChildByName('Scripts', children));
|
|
40
|
+
const hasSetLinks = Boolean(findTargetElementByComponent(Links, children) || findTargetChildByName('Links', children));
|
|
41
|
+
const hasSetBody = Boolean(findTargetElementByComponent(Body, children) || findTargetChildByName('Body', children));
|
|
42
|
+
const hasSetRoot = Boolean(findTargetElementByComponent(Root, children) || findTargetChildByName('Root', children));
|
|
31
43
|
const hasSetTitle = Boolean(findTargetElement('title', children));
|
|
32
44
|
const notMissMustChild = [
|
|
33
45
|
hasSetHead,
|
|
@@ -5,8 +5,8 @@ import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/const
|
|
|
5
5
|
import { resolveSSRMode } from "../../../cli/ssr/mode.mjs";
|
|
6
6
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants.mjs";
|
|
7
7
|
import { walk } from "./nestedRoutes.mjs";
|
|
8
|
-
import { fileSystemRoutes, routesForServer, ssrLoaderCombinedModule } from "./templates.mjs";
|
|
9
8
|
import { getServerCombinedModuleFile, getServerLoadersFile } from "./utils.mjs";
|
|
9
|
+
import * as __rspack_external__templates_mjs_4da4c6c8 from "./templates.mjs";
|
|
10
10
|
async function generateRoutesForEntry(entrypoint, appContext) {
|
|
11
11
|
const routes = [];
|
|
12
12
|
if (entrypoint.nestedRoutesEntry) {
|
|
@@ -81,7 +81,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
81
81
|
}
|
|
82
82
|
const { code } = await hooks.onBeforeGenerateRoutes.call({
|
|
83
83
|
entrypoint,
|
|
84
|
-
code: await fileSystemRoutes({
|
|
84
|
+
code: await __rspack_external__templates_mjs_4da4c6c8.fileSystemRoutes({
|
|
85
85
|
metaName,
|
|
86
86
|
routes: routes,
|
|
87
87
|
ssrMode: isUseRsc(config) ? 'stream' : ssrMode,
|
|
@@ -98,12 +98,12 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
98
98
|
const routesServerFile = getServerLoadersFile(internalDirectory, entryName);
|
|
99
99
|
const filtedRoutesForServer = filterRoutesForServer(routes);
|
|
100
100
|
const routesForServerLoaderMatches = filterRoutesLoader(routes);
|
|
101
|
-
const code = routesForServer({
|
|
101
|
+
const code = __rspack_external__templates_mjs_4da4c6c8.routesForServer({
|
|
102
102
|
routesForServerLoaderMatches
|
|
103
103
|
});
|
|
104
104
|
await fs.ensureFile(routesServerFile);
|
|
105
105
|
await fs.writeFile(routesServerFile, code);
|
|
106
|
-
const serverRoutesCode = await fileSystemRoutes({
|
|
106
|
+
const serverRoutesCode = await __rspack_external__templates_mjs_4da4c6c8.fileSystemRoutes({
|
|
107
107
|
metaName,
|
|
108
108
|
routes: filtedRoutesForServer,
|
|
109
109
|
ssrMode,
|
|
@@ -117,7 +117,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
117
117
|
});
|
|
118
118
|
await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/routes.server.js`), serverRoutesCode, 'utf8');
|
|
119
119
|
}
|
|
120
|
-
const serverLoaderCombined = ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
|
|
120
|
+
const serverLoaderCombined = __rspack_external__templates_mjs_4da4c6c8.ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
|
|
121
121
|
if (serverLoaderCombined) {
|
|
122
122
|
const serverLoaderFile = getServerCombinedModuleFile(internalDirectory, entryName);
|
|
123
123
|
await fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { extname as external_path_extname, join, relative, sep } from "path";
|
|
2
1
|
import { JS_EXTENSIONS, fs, normalizeToPosixPath } from "@modern-js/utils";
|
|
3
2
|
import { NESTED_ROUTE } from "../constants.mjs";
|
|
4
3
|
import { getPathWithoutExt, hasAction, replaceWithAlias } from "./utils.mjs";
|
|
4
|
+
import * as __rspack_external_path from "path";
|
|
5
5
|
const conventionNames = Object.values(NESTED_ROUTE);
|
|
6
6
|
const replaceDynamicPath = (routePath)=>routePath.replace(/\[(.*?)\]/g, ':$1');
|
|
7
7
|
const getRouteId = (componentPath, routesDir, entryName, isMainEntry)=>{
|
|
8
|
-
const relativePath = normalizeToPosixPath(relative(routesDir, componentPath));
|
|
8
|
+
const relativePath = normalizeToPosixPath(__rspack_external_path.relative(routesDir, componentPath));
|
|
9
9
|
const pathWithoutExt = getPathWithoutExt(relativePath);
|
|
10
10
|
let id = "";
|
|
11
11
|
id = isMainEntry ? pathWithoutExt : `${entryName}_${pathWithoutExt}`;
|
|
@@ -64,8 +64,8 @@ const walk = async (options)=>{
|
|
|
64
64
|
if (!await fs.pathExists(dirname)) return null;
|
|
65
65
|
const isDirectory = (await fs.stat(dirname)).isDirectory();
|
|
66
66
|
if (!isDirectory) return null;
|
|
67
|
-
const relativeDir = relative(rootDir, dirname);
|
|
68
|
-
const pathSegments = relativeDir.split(sep);
|
|
67
|
+
const relativeDir = __rspack_external_path.relative(rootDir, dirname);
|
|
68
|
+
const pathSegments = relativeDir.split(__rspack_external_path.sep);
|
|
69
69
|
const lastSegment = pathSegments[pathSegments.length - 1];
|
|
70
70
|
const isRoot = '' === lastSegment;
|
|
71
71
|
const isPathlessLayout = lastSegment.startsWith('__');
|
|
@@ -93,9 +93,9 @@ const walk = async (options)=>{
|
|
|
93
93
|
let splatAction = '';
|
|
94
94
|
const items = await fs.readdir(dirname);
|
|
95
95
|
for (const item of items){
|
|
96
|
-
const itemPath = join(dirname, item);
|
|
96
|
+
const itemPath = __rspack_external_path.join(dirname, item);
|
|
97
97
|
const itemPathWithAlias = alias ? getPathWithoutExt(replaceWithAlias(alias.basename, itemPath, alias.name)) : getPathWithoutExt(itemPath);
|
|
98
|
-
const extname =
|
|
98
|
+
const extname = __rspack_external_path.extname(item);
|
|
99
99
|
const itemWithoutExt = item.slice(0, -extname.length);
|
|
100
100
|
const isDirectory = (await fs.stat(itemPath)).isDirectory();
|
|
101
101
|
if (isDirectory) {
|
|
@@ -168,7 +168,7 @@ const walk = async (options)=>{
|
|
|
168
168
|
let finalRoute = createRoute({
|
|
169
169
|
...route,
|
|
170
170
|
origin: 'file-system'
|
|
171
|
-
}, rootDir, join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`), entryName, isMainEntry);
|
|
171
|
+
}, rootDir, __rspack_external_path.join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`), entryName, isMainEntry);
|
|
172
172
|
if (isPathlessLayout) delete finalRoute.path;
|
|
173
173
|
const childRoutes = finalRoute.children = finalRoute.children?.filter((childRoute)=>childRoute);
|
|
174
174
|
if (childRoutes && 0 === childRoutes.length && !finalRoute.index && !finalRoute._component) return null;
|
|
@@ -34,7 +34,12 @@ const parseModule = async ({ source, filename })=>{
|
|
|
34
34
|
if (JS_EXTENSIONS.some((ext)=>filename.endsWith(ext))) {
|
|
35
35
|
const result = await transform(content, {
|
|
36
36
|
loader: path.extname(filename).slice(1),
|
|
37
|
-
format: 'esm'
|
|
37
|
+
format: 'esm',
|
|
38
|
+
tsconfigRaw: {
|
|
39
|
+
compilerOptions: {
|
|
40
|
+
experimentalDecorators: true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
38
43
|
});
|
|
39
44
|
content = result.code;
|
|
40
45
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { getMeta } from "@modern-js/utils";
|
|
3
3
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
4
|
-
import { runtimeGlobalContext } from "./code/templates.mjs";
|
|
5
4
|
import { isPageComponentFile } from "./code/utils.mjs";
|
|
6
5
|
import { modifyEntrypoints } from "./entry.mjs";
|
|
6
|
+
import * as __rspack_external__code_templates_mjs_5e908598 from "./code/templates.mjs";
|
|
7
7
|
let originEntrypoints = [];
|
|
8
8
|
async function handleModifyEntrypoints(entrypoints) {
|
|
9
9
|
return modifyEntrypoints(entrypoints);
|
|
@@ -20,7 +20,7 @@ async function handleGeneratorEntryCode(api, entrypoints) {
|
|
|
20
20
|
if (entrypoint.nestedRoutesEntry || entrypoint.pageRoutesEntry) {
|
|
21
21
|
const route = appContext.serverRoutes.find((r)=>r.entryName === entrypoint.entryName);
|
|
22
22
|
const basename = route?.urlPath || '/';
|
|
23
|
-
generatorRegisterCode(internalDirectory, entrypoint.entryName, await runtimeGlobalContext({
|
|
23
|
+
generatorRegisterCode(internalDirectory, entrypoint.entryName, await __rspack_external__code_templates_mjs_5e908598.runtimeGlobalContext({
|
|
24
24
|
entryName: entrypoint.entryName,
|
|
25
25
|
metaName: appContext.metaName,
|
|
26
26
|
srcDirectory: appContext.srcDirectory,
|
|
@@ -30,7 +30,7 @@ async function handleGeneratorEntryCode(api, entrypoints) {
|
|
|
30
30
|
rscType: enableRsc ? 'client' : void 0,
|
|
31
31
|
basename
|
|
32
32
|
}));
|
|
33
|
-
if (enableRsc) generatorServerRegisterCode(internalDirectory, entrypoint.entryName, await runtimeGlobalContext({
|
|
33
|
+
if (enableRsc) generatorServerRegisterCode(internalDirectory, entrypoint.entryName, await __rspack_external__code_templates_mjs_5e908598.runtimeGlobalContext({
|
|
34
34
|
entryName: entrypoint.entryName,
|
|
35
35
|
metaName: appContext.metaName,
|
|
36
36
|
srcDirectory: appContext.srcDirectory,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { useRouteLoaderData } from "@modern-js/runtime-utils/router";
|
|
1
2
|
export * from "@modern-js/runtime-utils/router";
|
|
2
3
|
export * from "./withRouter.mjs";
|
|
3
|
-
import { useRouteLoaderData } from "@modern-js/runtime-utils/router";
|
|
4
4
|
const runtime_useRouteLoaderData = (routeId)=>{
|
|
5
5
|
const realRouteId = routeId.replace(/\[(.*?)\]/g, '($1)');
|
|
6
6
|
return useRouteLoaderData(realRouteId);
|
|
@@ -3,8 +3,8 @@ import path from "path";
|
|
|
3
3
|
import { fs } from "@modern-js/utils";
|
|
4
4
|
import { ENTRY_BOOTSTRAP_FILE_NAME, ENTRY_POINT_FILE_NAME, ENTRY_POINT_REGISTER_FILE_NAME, ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME, ENTRY_POINT_RUNTIME_REGISTER_FILE_NAME, ENTRY_SERVER_BOOTSTRAP_FILE_NAME, INDEX_FILE_NAME, SERVER_ENTRY_POINT_FILE_NAME } from "./constants.mjs";
|
|
5
5
|
import { resolveSSRMode } from "./ssr/mode.mjs";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import * as __rspack_external__template_mjs_d6ab8956 from "./template.mjs";
|
|
7
|
+
import * as __rspack_external__template_server_mjs_38d6edb1 from "./template.server.mjs";
|
|
8
8
|
const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
9
9
|
const { mountId } = config.html;
|
|
10
10
|
const { enableAsyncEntry } = config.source;
|
|
@@ -22,7 +22,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
22
22
|
nestedRoutesEntry
|
|
23
23
|
});
|
|
24
24
|
let indexCode = '';
|
|
25
|
-
indexCode = ssrMode || !config.server.rsc || customEntry ? index({
|
|
25
|
+
indexCode = ssrMode || !config.server.rsc || customEntry ? __rspack_external__template_mjs_d6ab8956.index({
|
|
26
26
|
srcDirectory,
|
|
27
27
|
internalSrcAlias,
|
|
28
28
|
metaName,
|
|
@@ -32,7 +32,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
32
32
|
mountId,
|
|
33
33
|
enableRsc: config.server.rsc,
|
|
34
34
|
isNestedRouter: !!entrypoint.nestedRoutesEntry
|
|
35
|
-
}) : entryForCSRWithRSC({
|
|
35
|
+
}) : __rspack_external__template_mjs_d6ab8956.entryForCSRWithRSC({
|
|
36
36
|
metaName,
|
|
37
37
|
entryName,
|
|
38
38
|
mountId,
|
|
@@ -48,7 +48,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
48
48
|
if (ssrMode) await fs.outputFile(bootstrapServerFile, `export const requestHandler = import('./${SERVER_ENTRY_POINT_FILE_NAME}').then((m) => m.requestHandler)`, 'utf8');
|
|
49
49
|
}
|
|
50
50
|
if (ssrMode) {
|
|
51
|
-
const indexServerCode = serverIndex({
|
|
51
|
+
const indexServerCode = __rspack_external__template_server_mjs_38d6edb1.serverIndex({
|
|
52
52
|
entry,
|
|
53
53
|
entryName,
|
|
54
54
|
internalSrcAlias,
|
|
@@ -62,16 +62,16 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
62
62
|
await fs.outputFile(indexServerFile, indexServerCode, 'utf8');
|
|
63
63
|
} else if (config.server.rsc) {
|
|
64
64
|
const indexServerFile = path.resolve(internalDirectory, `./${entryName}/${SERVER_ENTRY_POINT_FILE_NAME}`);
|
|
65
|
-
const indexServerCode =
|
|
65
|
+
const indexServerCode = __rspack_external__template_server_mjs_38d6edb1.entryForCSRWithRSC({
|
|
66
66
|
entryName,
|
|
67
67
|
metaName
|
|
68
68
|
});
|
|
69
69
|
await fs.outputFile(indexServerFile, indexServerCode, 'utf8');
|
|
70
70
|
}
|
|
71
|
-
const registerCode = register();
|
|
71
|
+
const registerCode = __rspack_external__template_mjs_d6ab8956.register();
|
|
72
72
|
const registerFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_REGISTER_FILE_NAME}`);
|
|
73
73
|
await fs.outputFile(registerFile, registerCode, 'utf8');
|
|
74
|
-
const registerRuntimeCode = runtimeRegister({
|
|
74
|
+
const registerRuntimeCode = __rspack_external__template_mjs_d6ab8956.runtimeRegister({
|
|
75
75
|
entryName,
|
|
76
76
|
srcDirectory,
|
|
77
77
|
internalSrcAlias,
|
|
@@ -85,7 +85,7 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
85
85
|
if (!config.server.rsc || entrypoint.nestedRoutesEntry) {
|
|
86
86
|
const route = serverRoutes.find((r)=>r.entryName === entryName);
|
|
87
87
|
const basename = route?.urlPath || '/';
|
|
88
|
-
contextCode = runtimeGlobalContext({
|
|
88
|
+
contextCode = __rspack_external__template_mjs_d6ab8956.runtimeGlobalContext({
|
|
89
89
|
entryName,
|
|
90
90
|
srcDirectory,
|
|
91
91
|
internalSrcAlias,
|
|
@@ -96,18 +96,18 @@ const generateCode = async (entrypoints, appContext, config, hooks)=>{
|
|
|
96
96
|
});
|
|
97
97
|
} else {
|
|
98
98
|
const AppProxyPath = path.join(internalDirectory, entryName, './AppProxy.jsx');
|
|
99
|
-
const appProxyCode = AppProxyForRSC({
|
|
99
|
+
const appProxyCode = __rspack_external__template_mjs_d6ab8956.AppProxyForRSC({
|
|
100
100
|
srcDirectory,
|
|
101
101
|
internalSrcAlias,
|
|
102
102
|
entry,
|
|
103
103
|
customEntry
|
|
104
104
|
});
|
|
105
105
|
await fs.outputFile(AppProxyPath, appProxyCode);
|
|
106
|
-
contextCode = runtimeGlobalContextForRSCClient({
|
|
106
|
+
contextCode = __rspack_external__template_mjs_d6ab8956.runtimeGlobalContextForRSCClient({
|
|
107
107
|
metaName,
|
|
108
108
|
customEntry
|
|
109
109
|
});
|
|
110
|
-
const contextServerCode = runtimeGlobalContextForRSCServer({
|
|
110
|
+
const contextServerCode = __rspack_external__template_mjs_d6ab8956.runtimeGlobalContextForRSCServer({
|
|
111
111
|
metaName
|
|
112
112
|
});
|
|
113
113
|
const contextFile = path.resolve(internalDirectory, `./${entryName}/${ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME}.server.js`);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
3
|
-
import { dirname as __rspack_dirname } from "node:path";
|
|
4
2
|
import { matchRoutes } from "@modern-js/runtime-utils/router";
|
|
5
3
|
import react_helmet from "react-helmet";
|
|
6
4
|
import { CHUNK_CSS_PLACEHOLDER } from "../constants.mjs";
|
|
7
5
|
import { createReplaceHelemt } from "../helmet.mjs";
|
|
8
6
|
import { buildHtml } from "../shared.mjs";
|
|
9
7
|
import { checkIsNode, safeReplace } from "../utils.mjs";
|
|
8
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
9
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
10
10
|
var beforeTemplate_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
11
11
|
const readAsset = async (chunk)=>{
|
|
12
12
|
const fs = await import("fs/promises");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
3
|
-
import { dirname as __rspack_dirname } from "node:path";
|
|
4
2
|
import { ChunkExtractor } from "@loadable/server";
|
|
5
3
|
import { attributesToString, checkIsNode } from "../utils.mjs";
|
|
4
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
5
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
6
6
|
var loadable_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
7
7
|
const extname = (uri)=>{
|
|
8
8
|
if ('string' != typeof uri || !uri.includes('.')) return '';
|
|
@@ -4,12 +4,24 @@ import "react";
|
|
|
4
4
|
import { Body } from "./Body.mjs";
|
|
5
5
|
import { DocumentStructureContext } from "./DocumentStructureContext.mjs";
|
|
6
6
|
import { Head } from "./Head.mjs";
|
|
7
|
+
import { Links } from "./Links.mjs";
|
|
8
|
+
import { Root } from "./Root.mjs";
|
|
9
|
+
import { Scripts } from "./Scripts.mjs";
|
|
7
10
|
function findTargetChildByName(tag, children) {
|
|
8
11
|
return children.find((item)=>getEleType(item) === tag);
|
|
9
12
|
}
|
|
10
13
|
function findTargetChildByComponent(component, children) {
|
|
11
14
|
return children.find((item)=>item?.type === component);
|
|
12
15
|
}
|
|
16
|
+
function findTargetElementByComponent(component, children) {
|
|
17
|
+
if (0 === children.length) return null;
|
|
18
|
+
let nextChildren = [];
|
|
19
|
+
for (const item of children){
|
|
20
|
+
if (item?.type === component) return item;
|
|
21
|
+
if (item?.props?.children) nextChildren = nextChildren.concat(item.props.children);
|
|
22
|
+
}
|
|
23
|
+
return findTargetElementByComponent(component, nextChildren);
|
|
24
|
+
}
|
|
13
25
|
function getEleType(ele) {
|
|
14
26
|
return 'function' == typeof ele?.type ? ele.type.name : ele?.type;
|
|
15
27
|
}
|
|
@@ -25,10 +37,10 @@ function findTargetElement(tag, children) {
|
|
|
25
37
|
function Html(props) {
|
|
26
38
|
const { children, ...rest } = props;
|
|
27
39
|
const hasSetHead = Boolean(findTargetChildByComponent(Head, children) || findTargetChildByName('Head', children));
|
|
28
|
-
const hasSetScripts = Boolean(
|
|
29
|
-
const hasSetLinks = Boolean(
|
|
30
|
-
const hasSetBody = Boolean(
|
|
31
|
-
const hasSetRoot = Boolean(
|
|
40
|
+
const hasSetScripts = Boolean(findTargetElementByComponent(Scripts, children) || findTargetChildByName('Scripts', children));
|
|
41
|
+
const hasSetLinks = Boolean(findTargetElementByComponent(Links, children) || findTargetChildByName('Links', children));
|
|
42
|
+
const hasSetBody = Boolean(findTargetElementByComponent(Body, children) || findTargetChildByName('Body', children));
|
|
43
|
+
const hasSetRoot = Boolean(findTargetElementByComponent(Root, children) || findTargetChildByName('Root', children));
|
|
32
44
|
const hasSetTitle = Boolean(findTargetElement('title', children));
|
|
33
45
|
const notMissMustChild = [
|
|
34
46
|
hasSetHead,
|
|
@@ -6,8 +6,8 @@ import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/const
|
|
|
6
6
|
import { resolveSSRMode } from "../../../cli/ssr/mode.mjs";
|
|
7
7
|
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants.mjs";
|
|
8
8
|
import { walk } from "./nestedRoutes.mjs";
|
|
9
|
-
import { fileSystemRoutes, routesForServer, ssrLoaderCombinedModule } from "./templates.mjs";
|
|
10
9
|
import { getServerCombinedModuleFile, getServerLoadersFile } from "./utils.mjs";
|
|
10
|
+
import * as __rspack_external__templates_mjs_4da4c6c8 from "./templates.mjs";
|
|
11
11
|
async function generateRoutesForEntry(entrypoint, appContext) {
|
|
12
12
|
const routes = [];
|
|
13
13
|
if (entrypoint.nestedRoutesEntry) {
|
|
@@ -82,7 +82,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
82
82
|
}
|
|
83
83
|
const { code } = await hooks.onBeforeGenerateRoutes.call({
|
|
84
84
|
entrypoint,
|
|
85
|
-
code: await fileSystemRoutes({
|
|
85
|
+
code: await __rspack_external__templates_mjs_4da4c6c8.fileSystemRoutes({
|
|
86
86
|
metaName,
|
|
87
87
|
routes: routes,
|
|
88
88
|
ssrMode: isUseRsc(config) ? 'stream' : ssrMode,
|
|
@@ -99,12 +99,12 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
99
99
|
const routesServerFile = getServerLoadersFile(internalDirectory, entryName);
|
|
100
100
|
const filtedRoutesForServer = filterRoutesForServer(routes);
|
|
101
101
|
const routesForServerLoaderMatches = filterRoutesLoader(routes);
|
|
102
|
-
const code = routesForServer({
|
|
102
|
+
const code = __rspack_external__templates_mjs_4da4c6c8.routesForServer({
|
|
103
103
|
routesForServerLoaderMatches
|
|
104
104
|
});
|
|
105
105
|
await fs.ensureFile(routesServerFile);
|
|
106
106
|
await fs.writeFile(routesServerFile, code);
|
|
107
|
-
const serverRoutesCode = await fileSystemRoutes({
|
|
107
|
+
const serverRoutesCode = await __rspack_external__templates_mjs_4da4c6c8.fileSystemRoutes({
|
|
108
108
|
metaName,
|
|
109
109
|
routes: filtedRoutesForServer,
|
|
110
110
|
ssrMode,
|
|
@@ -118,7 +118,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
118
118
|
});
|
|
119
119
|
await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/routes.server.js`), serverRoutesCode, 'utf8');
|
|
120
120
|
}
|
|
121
|
-
const serverLoaderCombined = ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
|
|
121
|
+
const serverLoaderCombined = __rspack_external__templates_mjs_4da4c6c8.ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
|
|
122
122
|
if (serverLoaderCombined) {
|
|
123
123
|
const serverLoaderFile = getServerCombinedModuleFile(internalDirectory, entryName);
|
|
124
124
|
await fs.outputFile(serverLoaderFile, serverLoaderCombined);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { extname as external_path_extname, join, relative, sep } from "path";
|
|
3
2
|
import { JS_EXTENSIONS, fs, normalizeToPosixPath } from "@modern-js/utils";
|
|
4
3
|
import { NESTED_ROUTE } from "../constants.mjs";
|
|
5
4
|
import { getPathWithoutExt, hasAction, replaceWithAlias } from "./utils.mjs";
|
|
5
|
+
import * as __rspack_external_path from "path";
|
|
6
6
|
const conventionNames = Object.values(NESTED_ROUTE);
|
|
7
7
|
const replaceDynamicPath = (routePath)=>routePath.replace(/\[(.*?)\]/g, ':$1');
|
|
8
8
|
const getRouteId = (componentPath, routesDir, entryName, isMainEntry)=>{
|
|
9
|
-
const relativePath = normalizeToPosixPath(relative(routesDir, componentPath));
|
|
9
|
+
const relativePath = normalizeToPosixPath(__rspack_external_path.relative(routesDir, componentPath));
|
|
10
10
|
const pathWithoutExt = getPathWithoutExt(relativePath);
|
|
11
11
|
let id = "";
|
|
12
12
|
id = isMainEntry ? pathWithoutExt : `${entryName}_${pathWithoutExt}`;
|
|
@@ -65,8 +65,8 @@ const walk = async (options)=>{
|
|
|
65
65
|
if (!await fs.pathExists(dirname)) return null;
|
|
66
66
|
const isDirectory = (await fs.stat(dirname)).isDirectory();
|
|
67
67
|
if (!isDirectory) return null;
|
|
68
|
-
const relativeDir = relative(rootDir, dirname);
|
|
69
|
-
const pathSegments = relativeDir.split(sep);
|
|
68
|
+
const relativeDir = __rspack_external_path.relative(rootDir, dirname);
|
|
69
|
+
const pathSegments = relativeDir.split(__rspack_external_path.sep);
|
|
70
70
|
const lastSegment = pathSegments[pathSegments.length - 1];
|
|
71
71
|
const isRoot = '' === lastSegment;
|
|
72
72
|
const isPathlessLayout = lastSegment.startsWith('__');
|
|
@@ -94,9 +94,9 @@ const walk = async (options)=>{
|
|
|
94
94
|
let splatAction = '';
|
|
95
95
|
const items = await fs.readdir(dirname);
|
|
96
96
|
for (const item of items){
|
|
97
|
-
const itemPath = join(dirname, item);
|
|
97
|
+
const itemPath = __rspack_external_path.join(dirname, item);
|
|
98
98
|
const itemPathWithAlias = alias ? getPathWithoutExt(replaceWithAlias(alias.basename, itemPath, alias.name)) : getPathWithoutExt(itemPath);
|
|
99
|
-
const extname =
|
|
99
|
+
const extname = __rspack_external_path.extname(item);
|
|
100
100
|
const itemWithoutExt = item.slice(0, -extname.length);
|
|
101
101
|
const isDirectory = (await fs.stat(itemPath)).isDirectory();
|
|
102
102
|
if (isDirectory) {
|
|
@@ -169,7 +169,7 @@ const walk = async (options)=>{
|
|
|
169
169
|
let finalRoute = createRoute({
|
|
170
170
|
...route,
|
|
171
171
|
origin: 'file-system'
|
|
172
|
-
}, rootDir, join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`), entryName, isMainEntry);
|
|
172
|
+
}, rootDir, __rspack_external_path.join(dirname, `${NESTED_ROUTE.LAYOUT_FILE}.ts`), entryName, isMainEntry);
|
|
173
173
|
if (isPathlessLayout) delete finalRoute.path;
|
|
174
174
|
const childRoutes = finalRoute.children = finalRoute.children?.filter((childRoute)=>childRoute);
|
|
175
175
|
if (childRoutes && 0 === childRoutes.length && !finalRoute.index && !finalRoute._component) return null;
|
|
@@ -35,7 +35,12 @@ const parseModule = async ({ source, filename })=>{
|
|
|
35
35
|
if (JS_EXTENSIONS.some((ext)=>filename.endsWith(ext))) {
|
|
36
36
|
const result = await transform(content, {
|
|
37
37
|
loader: path.extname(filename).slice(1),
|
|
38
|
-
format: 'esm'
|
|
38
|
+
format: 'esm',
|
|
39
|
+
tsconfigRaw: {
|
|
40
|
+
compilerOptions: {
|
|
41
|
+
experimentalDecorators: true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
39
44
|
});
|
|
40
45
|
content = result.code;
|
|
41
46
|
}
|
|
@@ -2,9 +2,9 @@ import "node:module";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { getMeta } from "@modern-js/utils";
|
|
4
4
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
5
|
-
import { runtimeGlobalContext } from "./code/templates.mjs";
|
|
6
5
|
import { isPageComponentFile } from "./code/utils.mjs";
|
|
7
6
|
import { modifyEntrypoints } from "./entry.mjs";
|
|
7
|
+
import * as __rspack_external__code_templates_mjs_5e908598 from "./code/templates.mjs";
|
|
8
8
|
let originEntrypoints = [];
|
|
9
9
|
async function handleModifyEntrypoints(entrypoints) {
|
|
10
10
|
return modifyEntrypoints(entrypoints);
|
|
@@ -21,7 +21,7 @@ async function handleGeneratorEntryCode(api, entrypoints) {
|
|
|
21
21
|
if (entrypoint.nestedRoutesEntry || entrypoint.pageRoutesEntry) {
|
|
22
22
|
const route = appContext.serverRoutes.find((r)=>r.entryName === entrypoint.entryName);
|
|
23
23
|
const basename = route?.urlPath || '/';
|
|
24
|
-
generatorRegisterCode(internalDirectory, entrypoint.entryName, await runtimeGlobalContext({
|
|
24
|
+
generatorRegisterCode(internalDirectory, entrypoint.entryName, await __rspack_external__code_templates_mjs_5e908598.runtimeGlobalContext({
|
|
25
25
|
entryName: entrypoint.entryName,
|
|
26
26
|
metaName: appContext.metaName,
|
|
27
27
|
srcDirectory: appContext.srcDirectory,
|
|
@@ -31,7 +31,7 @@ async function handleGeneratorEntryCode(api, entrypoints) {
|
|
|
31
31
|
rscType: enableRsc ? 'client' : void 0,
|
|
32
32
|
basename
|
|
33
33
|
}));
|
|
34
|
-
if (enableRsc) generatorServerRegisterCode(internalDirectory, entrypoint.entryName, await runtimeGlobalContext({
|
|
34
|
+
if (enableRsc) generatorServerRegisterCode(internalDirectory, entrypoint.entryName, await __rspack_external__code_templates_mjs_5e908598.runtimeGlobalContext({
|
|
35
35
|
entryName: entrypoint.entryName,
|
|
36
36
|
metaName: appContext.metaName,
|
|
37
37
|
srcDirectory: appContext.srcDirectory,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
3
|
-
import { dirname as __rspack_dirname } from "node:path";
|
|
4
2
|
import node_path from "node:path";
|
|
5
3
|
import { NESTED_ROUTE_SPEC_FILE, filterRoutesForServer, fs } from "@modern-js/utils";
|
|
6
4
|
import { isRouteEntry } from "./entry.mjs";
|
|
7
5
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler.mjs";
|
|
6
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
7
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
8
8
|
var cli_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
9
9
|
const routerPlugin = ()=>({
|
|
10
10
|
name: '@modern-js/plugin-router',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { useRouteLoaderData } from "@modern-js/runtime-utils/router";
|
|
2
3
|
export * from "@modern-js/runtime-utils/router";
|
|
3
4
|
export * from "./withRouter.mjs";
|
|
4
|
-
import { useRouteLoaderData } from "@modern-js/runtime-utils/router";
|
|
5
5
|
const runtime_useRouteLoaderData = (routeId)=>{
|
|
6
6
|
const realRouteId = routeId.replace(/\[(.*?)\]/g, '($1)');
|
|
7
7
|
return useRouteLoaderData(realRouteId);
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.1.
|
|
18
|
+
"version": "3.1.3",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
@@ -215,12 +215,12 @@
|
|
|
215
215
|
"isbot": "3.8.0",
|
|
216
216
|
"react-helmet": "^6.1.0",
|
|
217
217
|
"react-is": "^18.3.1",
|
|
218
|
-
"@modern-js/plugin
|
|
219
|
-
"@modern-js/
|
|
220
|
-
"@modern-js/
|
|
221
|
-
"@modern-js/
|
|
222
|
-
"@modern-js/
|
|
223
|
-
"@modern-js/
|
|
218
|
+
"@modern-js/plugin": "3.1.3",
|
|
219
|
+
"@modern-js/runtime-utils": "3.1.3",
|
|
220
|
+
"@modern-js/render": "3.1.3",
|
|
221
|
+
"@modern-js/plugin-data-loader": "3.1.3",
|
|
222
|
+
"@modern-js/utils": "3.1.3",
|
|
223
|
+
"@modern-js/types": "3.1.3"
|
|
224
224
|
},
|
|
225
225
|
"peerDependencies": {
|
|
226
226
|
"react": ">=17.0.2",
|
|
@@ -228,8 +228,8 @@
|
|
|
228
228
|
},
|
|
229
229
|
"devDependencies": {
|
|
230
230
|
"@remix-run/web-fetch": "^4.1.3",
|
|
231
|
-
"@rsbuild/core": "2.0.0-
|
|
232
|
-
"@rslib/core": "0.
|
|
231
|
+
"@rsbuild/core": "2.0.0-rc.0",
|
|
232
|
+
"@rslib/core": "0.21.0",
|
|
233
233
|
"@testing-library/dom": "^10.4.1",
|
|
234
234
|
"@testing-library/react": "^16.3.2",
|
|
235
235
|
"@types/cookie": "0.6.0",
|
|
@@ -240,9 +240,9 @@
|
|
|
240
240
|
"react-dom": "^19.2.4",
|
|
241
241
|
"ts-node": "^10.9.2",
|
|
242
242
|
"typescript": "^5",
|
|
243
|
-
"@modern-js/app-tools": "3.1.
|
|
244
|
-
"@
|
|
245
|
-
"@
|
|
243
|
+
"@modern-js/app-tools": "3.1.3",
|
|
244
|
+
"@modern-js/rslib": "2.68.10",
|
|
245
|
+
"@scripts/rstest-config": "2.66.0"
|
|
246
246
|
},
|
|
247
247
|
"sideEffects": false,
|
|
248
248
|
"publishConfig": {
|