@bleedingdev/modern-js-runtime 3.9.0-ultramodern.12 → 3.9.0-ultramodern.13
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/cli/template.server.js +1 -2
- package/dist/cjs/core/browser/hydrate.js +2 -2
- package/dist/cjs/core/server/stream/beforeTemplate.js +3 -3
- package/dist/cjs/core/server/stream/beforeTemplate.worker.js +2 -2
- package/dist/cjs/core/server/string/loadable.js +4 -4
- package/dist/cjs/router/cli/code/nestedRoutes.js +1 -2
- package/dist/cjs/router/cli/code/templates.js +1 -1
- package/dist/cjs/router/cli/code/utils.js +2 -2
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +10 -9
- package/dist/cjs/router/runtime/plugin.node.js +1 -1
- package/dist/esm/cli/template.server.mjs +1 -2
- package/dist/esm/core/browser/hydrate.mjs +2 -2
- package/dist/esm/core/server/stream/beforeTemplate.mjs +3 -3
- package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +2 -2
- package/dist/esm/core/server/string/loadable.mjs +4 -4
- package/dist/esm/router/cli/code/nestedRoutes.mjs +1 -2
- package/dist/esm/router/cli/code/templates.mjs +1 -1
- package/dist/esm/router/cli/code/utils.mjs +2 -2
- package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +10 -9
- package/dist/esm/router/runtime/plugin.node.mjs +1 -1
- package/dist/esm-node/cli/template.server.mjs +1 -2
- package/dist/esm-node/core/browser/hydrate.mjs +2 -2
- package/dist/esm-node/core/server/stream/beforeTemplate.mjs +3 -3
- package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +2 -2
- package/dist/esm-node/core/server/string/loadable.mjs +4 -4
- package/dist/esm-node/router/cli/code/nestedRoutes.mjs +1 -2
- package/dist/esm-node/router/cli/code/templates.mjs +1 -1
- package/dist/esm-node/router/cli/code/utils.mjs +2 -2
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +10 -9
- package/dist/esm-node/router/runtime/plugin.node.mjs +1 -1
- package/package.json +18 -18
|
@@ -153,8 +153,7 @@ function genHandlerCode({ mode, metaName, customServerEntry, srcDirectory, inter
|
|
|
153
153
|
return `
|
|
154
154
|
export * from '${realEntryPath}';
|
|
155
155
|
export { default as requestHandler } from '${realEntryPath}'`;
|
|
156
|
-
}
|
|
157
|
-
{
|
|
156
|
+
} else {
|
|
158
157
|
const entrySource = enableRsc ? SERVER_ENTRY_RSC : SERVER_ENTRY;
|
|
159
158
|
const serverEntry = transformServerEntry(entrySource, {
|
|
160
159
|
metaName: metaName || 'modern-js',
|
|
@@ -62,7 +62,7 @@ function hydrateRoot(App, context, ModernRender, ModernHydrate) {
|
|
|
62
62
|
if ('stream' === renderMode) return streamSSRHydrate();
|
|
63
63
|
function streamSSRHydrate() {
|
|
64
64
|
if (renderLevel !== external_constants_js_namespaceObject.RenderLevel.SERVER_RENDER) return ModernRender((0, wrapper_js_namespaceObject.wrapRuntimeContextProvider)(App, context));
|
|
65
|
-
{
|
|
65
|
+
else {
|
|
66
66
|
const SSRApp = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_withCallback_js_namespaceObject.WithCallback, {
|
|
67
67
|
callback: callback,
|
|
68
68
|
children: App
|
|
@@ -78,7 +78,7 @@ function hydrateRoot(App, context, ModernRender, ModernHydrate) {
|
|
|
78
78
|
return stringSSRHydrate();
|
|
79
79
|
function stringSSRHydrate() {
|
|
80
80
|
if (renderLevel === external_constants_js_namespaceObject.RenderLevel.CLIENT_RENDER) return ModernRender((0, wrapper_js_namespaceObject.wrapRuntimeContextProvider)(App, context));
|
|
81
|
-
{
|
|
81
|
+
else {
|
|
82
82
|
if (renderLevel === external_constants_js_namespaceObject.RenderLevel.SERVER_RENDER) return (0, component_namespaceObject.loadableReady)(()=>void 0, loadableReadyOptions).then(()=>{
|
|
83
83
|
const SSRApp = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_withCallback_js_namespaceObject.WithCallback, {
|
|
84
84
|
callback: callback,
|
|
@@ -43,8 +43,8 @@ const readAsset = async (chunk)=>{
|
|
|
43
43
|
};
|
|
44
44
|
const checkIsInline = (chunk, enableInline)=>{
|
|
45
45
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
46
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
47
|
-
return Boolean(enableInline);
|
|
46
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
47
|
+
else return Boolean(enableInline);
|
|
48
48
|
};
|
|
49
49
|
async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
50
50
|
const { config, runtimeContext, styledComponentsStyleTags, entryName, lifecycle, helmetData } = options;
|
|
@@ -102,7 +102,7 @@ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
|
102
102
|
const styles = await Promise.all(cssChunks.map(async (chunk)=>{
|
|
103
103
|
const link = `<link href="${chunk}" rel="stylesheet" />`;
|
|
104
104
|
if ((0, external_utils_js_namespaceObject.checkIsNode)() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
105
|
-
return link;
|
|
105
|
+
else return link;
|
|
106
106
|
}));
|
|
107
107
|
return `${styles.join('')}`;
|
|
108
108
|
}
|
|
@@ -36,8 +36,8 @@ const external_shared_js_namespaceObject = require("../shared.js");
|
|
|
36
36
|
const external_utils_js_namespaceObject = require("../utils.js");
|
|
37
37
|
const checkIsInline = (chunk, enableInline)=>{
|
|
38
38
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
39
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
40
|
-
return Boolean(enableInline);
|
|
39
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
40
|
+
else return Boolean(enableInline);
|
|
41
41
|
};
|
|
42
42
|
async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
43
43
|
const { config, runtimeContext, styledComponentsStyleTags, entryName, lifecycle, helmetData } = options;
|
|
@@ -48,8 +48,8 @@ const assetToChunk = (asset)=>({
|
|
|
48
48
|
});
|
|
49
49
|
const checkIsInline = (chunk, enableInline)=>{
|
|
50
50
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
51
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
52
|
-
return Boolean(enableInline);
|
|
51
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
52
|
+
else return Boolean(enableInline);
|
|
53
53
|
};
|
|
54
54
|
const readAsset = async (chunk)=>{
|
|
55
55
|
const fs = await import("fs/promises");
|
|
@@ -142,7 +142,7 @@ class LoadableCollector {
|
|
|
142
142
|
const scripts = await Promise.all(chunks.filter((chunk)=>!existedScript.includes(chunk.url) && !this.existsAssets?.includes(chunk.path)).map(async (chunk)=>{
|
|
143
143
|
const script = `<script${attributes} src="${chunk.url}"></script>`;
|
|
144
144
|
if ((0, external_utils_js_namespaceObject.checkIsNode)() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<script>${content}</script>`).catch((_)=>script);
|
|
145
|
-
return script;
|
|
145
|
+
else return script;
|
|
146
146
|
}));
|
|
147
147
|
chunkSet.jsChunk += scripts.filter((script)=>Boolean(script)).join('');
|
|
148
148
|
}
|
|
@@ -159,7 +159,7 @@ class LoadableCollector {
|
|
|
159
159
|
const css = await Promise.all(emittedChunks.map(async (chunk)=>{
|
|
160
160
|
const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
|
|
161
161
|
if ((0, external_utils_js_namespaceObject.checkIsNode)() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
162
|
-
return link;
|
|
162
|
+
else return link;
|
|
163
163
|
}));
|
|
164
164
|
chunkSet.cssChunk += css.filter((css)=>Boolean(css)).join('');
|
|
165
165
|
this.stylesheetInfo.emittedAssets = emittedChunks.map((chunk)=>chunk.url);
|
|
@@ -76,8 +76,7 @@ const optimizeRoute = (routeTree)=>{
|
|
|
76
76
|
children: optimizedChildren
|
|
77
77
|
}
|
|
78
78
|
];
|
|
79
|
-
}
|
|
80
|
-
{
|
|
79
|
+
} else {
|
|
81
80
|
const newRoutes = children.map((child)=>{
|
|
82
81
|
const routePath = routeTree.path ? `${routeTree.path}${child.path ? `/${child.path}` : ''}` : child.path || '';
|
|
83
82
|
const newRoute = {
|
|
@@ -61,7 +61,7 @@ const walkDirectory = (dir)=>external_fs_default().readdirSync(dir).reduce((prev
|
|
|
61
61
|
...previous,
|
|
62
62
|
...walkDirectory(filePath)
|
|
63
63
|
];
|
|
64
|
-
return [
|
|
64
|
+
else return [
|
|
65
65
|
...previous,
|
|
66
66
|
filePath
|
|
67
67
|
];
|
|
@@ -78,7 +78,7 @@ const isPageComponentFile = (filePath)=>{
|
|
|
78
78
|
};
|
|
79
79
|
const replaceWithAlias = (base, filePath, alias)=>{
|
|
80
80
|
if (filePath.includes(base)) return (0, utils_namespaceObject.normalizeToPosixPath)(external_path_default().join(alias, external_path_default().relative(base, filePath)));
|
|
81
|
-
return filePath;
|
|
81
|
+
else return filePath;
|
|
82
82
|
};
|
|
83
83
|
const parseModule = async ({ source, filename })=>{
|
|
84
84
|
let content = source;
|
|
@@ -83,7 +83,7 @@ const DeferredDataScripts = (props)=>{
|
|
|
83
83
|
(0, node_namespaceObject.serializeJson)(key)
|
|
84
84
|
]
|
|
85
85
|
};
|
|
86
|
-
{
|
|
86
|
+
else {
|
|
87
87
|
const trackedPromise = deferredData.data[key];
|
|
88
88
|
if (void 0 !== trackedPromise._error) {
|
|
89
89
|
const error = toDeferredErrorInfo(trackedPromise._error);
|
|
@@ -95,15 +95,16 @@ const DeferredDataScripts = (props)=>{
|
|
|
95
95
|
(0, node_namespaceObject.serializeJson)(error)
|
|
96
96
|
]
|
|
97
97
|
};
|
|
98
|
+
} else {
|
|
99
|
+
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
100
|
+
return {
|
|
101
|
+
key,
|
|
102
|
+
routerDataFnName: 'p',
|
|
103
|
+
routerDataFnArgs: [
|
|
104
|
+
(0, node_namespaceObject.serializeJson)(trackedPromise._data)
|
|
105
|
+
]
|
|
106
|
+
};
|
|
98
107
|
}
|
|
99
|
-
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
100
|
-
return {
|
|
101
|
-
key,
|
|
102
|
-
routerDataFnName: 'p',
|
|
103
|
-
routerDataFnArgs: [
|
|
104
|
-
(0, node_namespaceObject.serializeJson)(trackedPromise._data)
|
|
105
|
-
]
|
|
106
|
-
};
|
|
107
108
|
}
|
|
108
109
|
});
|
|
109
110
|
return {
|
|
@@ -166,7 +166,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
166
166
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_rsc_router_js_namespaceObject.RSCStaticRouter, {
|
|
167
167
|
basename: basename
|
|
168
168
|
});
|
|
169
|
-
{
|
|
169
|
+
else {
|
|
170
170
|
const { nonce, mode, useJsonScript } = context.ssrContext;
|
|
171
171
|
const remixRouter = (0, router_namespaceObject.createStaticRouter)(routes, routerContext);
|
|
172
172
|
const routerWrapper = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
@@ -120,8 +120,7 @@ function genHandlerCode({ mode, metaName, customServerEntry, srcDirectory, inter
|
|
|
120
120
|
return `
|
|
121
121
|
export * from '${realEntryPath}';
|
|
122
122
|
export { default as requestHandler } from '${realEntryPath}'`;
|
|
123
|
-
}
|
|
124
|
-
{
|
|
123
|
+
} else {
|
|
125
124
|
const entrySource = enableRsc ? SERVER_ENTRY_RSC : SERVER_ENTRY;
|
|
126
125
|
const serverEntry = transformServerEntry(entrySource, {
|
|
127
126
|
metaName: metaName || 'modern-js',
|
|
@@ -29,7 +29,7 @@ function hydrate_hydrateRoot(App, context, ModernRender, ModernHydrate) {
|
|
|
29
29
|
if ('stream' === renderMode) return streamSSRHydrate();
|
|
30
30
|
function streamSSRHydrate() {
|
|
31
31
|
if (renderLevel !== RenderLevel.SERVER_RENDER) return ModernRender(wrapRuntimeContextProvider(App, context));
|
|
32
|
-
{
|
|
32
|
+
else {
|
|
33
33
|
const SSRApp = ()=>/*#__PURE__*/ jsx(WithCallback, {
|
|
34
34
|
callback: callback,
|
|
35
35
|
children: App
|
|
@@ -45,7 +45,7 @@ function hydrate_hydrateRoot(App, context, ModernRender, ModernHydrate) {
|
|
|
45
45
|
return stringSSRHydrate();
|
|
46
46
|
function stringSSRHydrate() {
|
|
47
47
|
if (renderLevel === RenderLevel.CLIENT_RENDER) return ModernRender(wrapRuntimeContextProvider(App, context));
|
|
48
|
-
{
|
|
48
|
+
else {
|
|
49
49
|
if (renderLevel === RenderLevel.SERVER_RENDER) return loadableReady(()=>void 0, loadableReadyOptions).then(()=>{
|
|
50
50
|
const SSRApp = ()=>/*#__PURE__*/ jsx(WithCallback, {
|
|
51
51
|
callback: callback,
|
|
@@ -11,8 +11,8 @@ const readAsset = async (chunk)=>{
|
|
|
11
11
|
};
|
|
12
12
|
const checkIsInline = (chunk, enableInline)=>{
|
|
13
13
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
14
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
15
|
-
return Boolean(enableInline);
|
|
14
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
15
|
+
else return Boolean(enableInline);
|
|
16
16
|
};
|
|
17
17
|
async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
18
18
|
const { config, runtimeContext, styledComponentsStyleTags, entryName, lifecycle, helmetData } = options;
|
|
@@ -70,7 +70,7 @@ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
|
70
70
|
const styles = await Promise.all(cssChunks.map(async (chunk)=>{
|
|
71
71
|
const link = `<link href="${chunk}" rel="stylesheet" />`;
|
|
72
72
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
73
|
-
return link;
|
|
73
|
+
else return link;
|
|
74
74
|
}));
|
|
75
75
|
return `${styles.join('')}`;
|
|
76
76
|
}
|
|
@@ -4,8 +4,8 @@ import { buildHtml, replaceSSRTemplateChunk } from "../shared.mjs";
|
|
|
4
4
|
import { hasStylesheetLink } from "../utils.mjs";
|
|
5
5
|
const checkIsInline = (chunk, enableInline)=>{
|
|
6
6
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
7
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
8
|
-
return Boolean(enableInline);
|
|
7
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
8
|
+
else return Boolean(enableInline);
|
|
9
9
|
};
|
|
10
10
|
async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
11
11
|
const { config, runtimeContext, styledComponentsStyleTags, entryName, lifecycle, helmetData } = options;
|
|
@@ -16,8 +16,8 @@ const assetToChunk = (asset)=>({
|
|
|
16
16
|
});
|
|
17
17
|
const checkIsInline = (chunk, enableInline)=>{
|
|
18
18
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
19
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
20
|
-
return Boolean(enableInline);
|
|
19
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
20
|
+
else return Boolean(enableInline);
|
|
21
21
|
};
|
|
22
22
|
const readAsset = async (chunk)=>{
|
|
23
23
|
const fs = await import("fs/promises");
|
|
@@ -110,7 +110,7 @@ class LoadableCollector {
|
|
|
110
110
|
const scripts = await Promise.all(chunks.filter((chunk)=>!existedScript.includes(chunk.url) && !this.existsAssets?.includes(chunk.path)).map(async (chunk)=>{
|
|
111
111
|
const script = `<script${attributes} src="${chunk.url}"></script>`;
|
|
112
112
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<script>${content}</script>`).catch((_)=>script);
|
|
113
|
-
return script;
|
|
113
|
+
else return script;
|
|
114
114
|
}));
|
|
115
115
|
chunkSet.jsChunk += scripts.filter((script)=>Boolean(script)).join('');
|
|
116
116
|
}
|
|
@@ -127,7 +127,7 @@ class LoadableCollector {
|
|
|
127
127
|
const css = await Promise.all(emittedChunks.map(async (chunk)=>{
|
|
128
128
|
const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
|
|
129
129
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
130
|
-
return link;
|
|
130
|
+
else return link;
|
|
131
131
|
}));
|
|
132
132
|
chunkSet.cssChunk += css.filter((css)=>Boolean(css)).join('');
|
|
133
133
|
this.stylesheetInfo.emittedAssets = emittedChunks.map((chunk)=>chunk.url);
|
|
@@ -42,8 +42,7 @@ const optimizeRoute = (routeTree)=>{
|
|
|
42
42
|
children: optimizedChildren
|
|
43
43
|
}
|
|
44
44
|
];
|
|
45
|
-
}
|
|
46
|
-
{
|
|
45
|
+
} else {
|
|
47
46
|
const newRoutes = children.map((child)=>{
|
|
48
47
|
const routePath = routeTree.path ? `${routeTree.path}${child.path ? `/${child.path}` : ''}` : child.path || '';
|
|
49
48
|
const newRoute = {
|
|
@@ -10,7 +10,7 @@ const walkDirectory = (dir)=>fs_0.readdirSync(dir).reduce((previous, filename)=>
|
|
|
10
10
|
...previous,
|
|
11
11
|
...walkDirectory(filePath)
|
|
12
12
|
];
|
|
13
|
-
return [
|
|
13
|
+
else return [
|
|
14
14
|
...previous,
|
|
15
15
|
filePath
|
|
16
16
|
];
|
|
@@ -27,7 +27,7 @@ const isPageComponentFile = (filePath)=>{
|
|
|
27
27
|
};
|
|
28
28
|
const replaceWithAlias = (base, filePath, alias)=>{
|
|
29
29
|
if (filePath.includes(base)) return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
|
30
|
-
return filePath;
|
|
30
|
+
else return filePath;
|
|
31
31
|
};
|
|
32
32
|
const parseModule = async ({ source, filename })=>{
|
|
33
33
|
let content = source;
|
|
@@ -51,7 +51,7 @@ const DeferredDataScripts = (props)=>{
|
|
|
51
51
|
serializeJson(key)
|
|
52
52
|
]
|
|
53
53
|
};
|
|
54
|
-
{
|
|
54
|
+
else {
|
|
55
55
|
const trackedPromise = deferredData.data[key];
|
|
56
56
|
if (void 0 !== trackedPromise._error) {
|
|
57
57
|
const error = toDeferredErrorInfo(trackedPromise._error);
|
|
@@ -63,15 +63,16 @@ const DeferredDataScripts = (props)=>{
|
|
|
63
63
|
serializeJson(error)
|
|
64
64
|
]
|
|
65
65
|
};
|
|
66
|
+
} else {
|
|
67
|
+
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
68
|
+
return {
|
|
69
|
+
key,
|
|
70
|
+
routerDataFnName: 'p',
|
|
71
|
+
routerDataFnArgs: [
|
|
72
|
+
serializeJson(trackedPromise._data)
|
|
73
|
+
]
|
|
74
|
+
};
|
|
66
75
|
}
|
|
67
|
-
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
68
|
-
return {
|
|
69
|
-
key,
|
|
70
|
-
routerDataFnName: 'p',
|
|
71
|
-
routerDataFnArgs: [
|
|
72
|
-
serializeJson(trackedPromise._data)
|
|
73
|
-
]
|
|
74
|
-
};
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
return {
|
|
@@ -123,7 +123,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
123
123
|
}) : /*#__PURE__*/ jsx(RSCStaticRouter, {
|
|
124
124
|
basename: basename
|
|
125
125
|
});
|
|
126
|
-
{
|
|
126
|
+
else {
|
|
127
127
|
const { nonce, mode, useJsonScript } = context.ssrContext;
|
|
128
128
|
const remixRouter = createStaticRouter(routes, routerContext);
|
|
129
129
|
const routerWrapper = /*#__PURE__*/ jsxs(Fragment, {
|
|
@@ -121,8 +121,7 @@ function genHandlerCode({ mode, metaName, customServerEntry, srcDirectory, inter
|
|
|
121
121
|
return `
|
|
122
122
|
export * from '${realEntryPath}';
|
|
123
123
|
export { default as requestHandler } from '${realEntryPath}'`;
|
|
124
|
-
}
|
|
125
|
-
{
|
|
124
|
+
} else {
|
|
126
125
|
const entrySource = enableRsc ? SERVER_ENTRY_RSC : SERVER_ENTRY;
|
|
127
126
|
const serverEntry = transformServerEntry(entrySource, {
|
|
128
127
|
metaName: metaName || 'modern-js',
|
|
@@ -30,7 +30,7 @@ function hydrate_hydrateRoot(App, context, ModernRender, ModernHydrate) {
|
|
|
30
30
|
if ('stream' === renderMode) return streamSSRHydrate();
|
|
31
31
|
function streamSSRHydrate() {
|
|
32
32
|
if (renderLevel !== RenderLevel.SERVER_RENDER) return ModernRender(wrapRuntimeContextProvider(App, context));
|
|
33
|
-
{
|
|
33
|
+
else {
|
|
34
34
|
const SSRApp = ()=>/*#__PURE__*/ jsx(WithCallback, {
|
|
35
35
|
callback: callback,
|
|
36
36
|
children: App
|
|
@@ -46,7 +46,7 @@ function hydrate_hydrateRoot(App, context, ModernRender, ModernHydrate) {
|
|
|
46
46
|
return stringSSRHydrate();
|
|
47
47
|
function stringSSRHydrate() {
|
|
48
48
|
if (renderLevel === RenderLevel.CLIENT_RENDER) return ModernRender(wrapRuntimeContextProvider(App, context));
|
|
49
|
-
{
|
|
49
|
+
else {
|
|
50
50
|
if (renderLevel === RenderLevel.SERVER_RENDER) return loadableReady(()=>void 0, loadableReadyOptions).then(()=>{
|
|
51
51
|
const SSRApp = ()=>/*#__PURE__*/ jsx(WithCallback, {
|
|
52
52
|
callback: callback,
|
|
@@ -15,8 +15,8 @@ const readAsset = async (chunk)=>{
|
|
|
15
15
|
};
|
|
16
16
|
const checkIsInline = (chunk, enableInline)=>{
|
|
17
17
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
18
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
19
|
-
return Boolean(enableInline);
|
|
18
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
19
|
+
else return Boolean(enableInline);
|
|
20
20
|
};
|
|
21
21
|
async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
22
22
|
const { config, runtimeContext, styledComponentsStyleTags, entryName, lifecycle, helmetData } = options;
|
|
@@ -74,7 +74,7 @@ async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
|
74
74
|
const styles = await Promise.all(cssChunks.map(async (chunk)=>{
|
|
75
75
|
const link = `<link href="${chunk}" rel="stylesheet" />`;
|
|
76
76
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
77
|
-
return link;
|
|
77
|
+
else return link;
|
|
78
78
|
}));
|
|
79
79
|
return `${styles.join('')}`;
|
|
80
80
|
}
|
|
@@ -5,8 +5,8 @@ import { buildHtml, replaceSSRTemplateChunk } from "../shared.mjs";
|
|
|
5
5
|
import { hasStylesheetLink } from "../utils.mjs";
|
|
6
6
|
const checkIsInline = (chunk, enableInline)=>{
|
|
7
7
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
8
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
9
|
-
return Boolean(enableInline);
|
|
8
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk);
|
|
9
|
+
else return Boolean(enableInline);
|
|
10
10
|
};
|
|
11
11
|
async function buildShellBeforeTemplate(beforeAppTemplate, options) {
|
|
12
12
|
const { config, runtimeContext, styledComponentsStyleTags, entryName, lifecycle, helmetData } = options;
|
|
@@ -20,8 +20,8 @@ const assetToChunk = (asset)=>({
|
|
|
20
20
|
});
|
|
21
21
|
const checkIsInline = (chunk, enableInline)=>{
|
|
22
22
|
if ('production' !== process.env.NODE_ENV) return false;
|
|
23
|
-
if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
24
|
-
return Boolean(enableInline);
|
|
23
|
+
else if (enableInline instanceof RegExp) return enableInline.test(chunk.url);
|
|
24
|
+
else return Boolean(enableInline);
|
|
25
25
|
};
|
|
26
26
|
const readAsset = async (chunk)=>{
|
|
27
27
|
const fs = await import("fs/promises");
|
|
@@ -114,7 +114,7 @@ class LoadableCollector {
|
|
|
114
114
|
const scripts = await Promise.all(chunks.filter((chunk)=>!existedScript.includes(chunk.url) && !this.existsAssets?.includes(chunk.path)).map(async (chunk)=>{
|
|
115
115
|
const script = `<script${attributes} src="${chunk.url}"></script>`;
|
|
116
116
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<script>${content}</script>`).catch((_)=>script);
|
|
117
|
-
return script;
|
|
117
|
+
else return script;
|
|
118
118
|
}));
|
|
119
119
|
chunkSet.jsChunk += scripts.filter((script)=>Boolean(script)).join('');
|
|
120
120
|
}
|
|
@@ -131,7 +131,7 @@ class LoadableCollector {
|
|
|
131
131
|
const css = await Promise.all(emittedChunks.map(async (chunk)=>{
|
|
132
132
|
const link = `<link${atrributes} href="${chunk.url}" rel="stylesheet" />`;
|
|
133
133
|
if (checkIsNode() && checkIsInline(chunk, inlineStyles)) return readAsset(chunk).then((content)=>`<style>${content}</style>`).catch((_)=>link);
|
|
134
|
-
return link;
|
|
134
|
+
else return link;
|
|
135
135
|
}));
|
|
136
136
|
chunkSet.cssChunk += css.filter((css)=>Boolean(css)).join('');
|
|
137
137
|
this.stylesheetInfo.emittedAssets = emittedChunks.map((chunk)=>chunk.url);
|
|
@@ -43,8 +43,7 @@ const optimizeRoute = (routeTree)=>{
|
|
|
43
43
|
children: optimizedChildren
|
|
44
44
|
}
|
|
45
45
|
];
|
|
46
|
-
}
|
|
47
|
-
{
|
|
46
|
+
} else {
|
|
48
47
|
const newRoutes = children.map((child)=>{
|
|
49
48
|
const routePath = routeTree.path ? `${routeTree.path}${child.path ? `/${child.path}` : ''}` : child.path || '';
|
|
50
49
|
const newRoute = {
|
|
@@ -11,7 +11,7 @@ const walkDirectory = (dir)=>fs_0.readdirSync(dir).reduce((previous, filename)=>
|
|
|
11
11
|
...previous,
|
|
12
12
|
...walkDirectory(filePath)
|
|
13
13
|
];
|
|
14
|
-
return [
|
|
14
|
+
else return [
|
|
15
15
|
...previous,
|
|
16
16
|
filePath
|
|
17
17
|
];
|
|
@@ -28,7 +28,7 @@ const isPageComponentFile = (filePath)=>{
|
|
|
28
28
|
};
|
|
29
29
|
const replaceWithAlias = (base, filePath, alias)=>{
|
|
30
30
|
if (filePath.includes(base)) return normalizeToPosixPath(path.join(alias, path.relative(base, filePath)));
|
|
31
|
-
return filePath;
|
|
31
|
+
else return filePath;
|
|
32
32
|
};
|
|
33
33
|
const parseModule = async ({ source, filename })=>{
|
|
34
34
|
let content = source;
|
|
@@ -52,7 +52,7 @@ const DeferredDataScripts = (props)=>{
|
|
|
52
52
|
serializeJson(key)
|
|
53
53
|
]
|
|
54
54
|
};
|
|
55
|
-
{
|
|
55
|
+
else {
|
|
56
56
|
const trackedPromise = deferredData.data[key];
|
|
57
57
|
if (void 0 !== trackedPromise._error) {
|
|
58
58
|
const error = toDeferredErrorInfo(trackedPromise._error);
|
|
@@ -64,15 +64,16 @@ const DeferredDataScripts = (props)=>{
|
|
|
64
64
|
serializeJson(error)
|
|
65
65
|
]
|
|
66
66
|
};
|
|
67
|
+
} else {
|
|
68
|
+
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
69
|
+
return {
|
|
70
|
+
key,
|
|
71
|
+
routerDataFnName: 'p',
|
|
72
|
+
routerDataFnArgs: [
|
|
73
|
+
serializeJson(trackedPromise._data)
|
|
74
|
+
]
|
|
75
|
+
};
|
|
67
76
|
}
|
|
68
|
-
if (void 0 === trackedPromise._data) throw new Error(`The deferred data for ${key} was not resolved, did you forget to return data from a deferred promise`);
|
|
69
|
-
return {
|
|
70
|
-
key,
|
|
71
|
-
routerDataFnName: 'p',
|
|
72
|
-
routerDataFnArgs: [
|
|
73
|
-
serializeJson(trackedPromise._data)
|
|
74
|
-
]
|
|
75
|
-
};
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
return {
|
|
@@ -124,7 +124,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
124
124
|
}) : /*#__PURE__*/ jsx(RSCStaticRouter, {
|
|
125
125
|
basename: basename
|
|
126
126
|
});
|
|
127
|
-
{
|
|
127
|
+
else {
|
|
128
128
|
const { nonce, mode, useJsonScript } = context.ssrContext;
|
|
129
129
|
const remixRouter = createStaticRouter(routes, routerContext);
|
|
130
130
|
const routerWrapper = /*#__PURE__*/ jsxs(Fragment, {
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"modern",
|
|
18
18
|
"modern.js"
|
|
19
19
|
],
|
|
20
|
-
"version": "3.9.0-ultramodern.
|
|
20
|
+
"version": "3.9.0-ultramodern.13",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20"
|
|
23
23
|
},
|
|
@@ -217,48 +217,48 @@
|
|
|
217
217
|
"dependencies": {
|
|
218
218
|
"@loadable/component": "5.16.7",
|
|
219
219
|
"@loadable/server": "5.16.7",
|
|
220
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.
|
|
221
|
-
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.
|
|
222
|
-
"@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.0-ultramodern.
|
|
223
|
-
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.
|
|
224
|
-
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.
|
|
225
|
-
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.
|
|
226
|
-
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.
|
|
227
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.
|
|
220
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.13",
|
|
221
|
+
"@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.13",
|
|
222
|
+
"@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.0-ultramodern.13",
|
|
223
|
+
"@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.13",
|
|
224
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.13",
|
|
225
|
+
"@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.13",
|
|
226
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.13",
|
|
227
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.13",
|
|
228
228
|
"@swc/core": "1.16.2",
|
|
229
229
|
"@swc/helpers": "^0.5.23",
|
|
230
230
|
"@swc/plugin-loadable-components": "^13.0.0",
|
|
231
231
|
"@types/loadable__component": "^5.13.10",
|
|
232
232
|
"@types/react-helmet": "^6.1.11",
|
|
233
233
|
"cookie": "2.0.1",
|
|
234
|
-
"entities": "^8.
|
|
234
|
+
"entities": "^8.1.0",
|
|
235
235
|
"es-module-lexer": "^2.3.2",
|
|
236
236
|
"esbuild": "^0.28.2",
|
|
237
237
|
"invariant": "^2.2.4",
|
|
238
238
|
"isbot": "5.2.2",
|
|
239
239
|
"react-helmet": "^6.1.0",
|
|
240
240
|
"react-helmet-async": "3.0.0",
|
|
241
|
-
"react-is": "^19.
|
|
241
|
+
"react-is": "^19.3.0"
|
|
242
242
|
},
|
|
243
243
|
"peerDependencies": {
|
|
244
244
|
"react": "^19.2.8",
|
|
245
245
|
"react-dom": "^19.2.8"
|
|
246
246
|
},
|
|
247
247
|
"devDependencies": {
|
|
248
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.
|
|
248
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.13",
|
|
249
249
|
"@remix-run/web-fetch": "^4.4.2",
|
|
250
|
-
"@rsbuild/core": "2.2.
|
|
251
|
-
"@rslib/core": "1.0.
|
|
250
|
+
"@rsbuild/core": "2.2.9",
|
|
251
|
+
"@rslib/core": "1.0.2",
|
|
252
252
|
"@scripts/rstest-config": "2.66.0",
|
|
253
|
-
"@testing-library/dom": "^10.4.
|
|
253
|
+
"@testing-library/dom": "^10.4.2",
|
|
254
254
|
"@testing-library/react": "^16.3.3",
|
|
255
255
|
"@types/cookie": "0.6.0",
|
|
256
256
|
"@types/invariant": "^2.2.37",
|
|
257
257
|
"@types/loadable__server": "5.12.11",
|
|
258
|
-
"@types/node": "^26.
|
|
258
|
+
"@types/node": "^26.6.2",
|
|
259
259
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
260
|
-
"react": "^19.
|
|
261
|
-
"react-dom": "^19.
|
|
260
|
+
"react": "^19.3.0",
|
|
261
|
+
"react-dom": "^19.3.0",
|
|
262
262
|
"ts-node": "^10.9.2",
|
|
263
263
|
"typescript": "^7.0.2"
|
|
264
264
|
},
|