@bleedingdev/modern-js-runtime 3.9.0-ultramodern.12 → 3.9.0-ultramodern.14

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.
Files changed (41) hide show
  1. package/dist/cjs/cli/template.server.js +1 -2
  2. package/dist/cjs/core/browser/hydrate.js +2 -2
  3. package/dist/cjs/core/server/stream/beforeTemplate.js +3 -3
  4. package/dist/cjs/core/server/stream/beforeTemplate.worker.js +2 -2
  5. package/dist/cjs/core/server/stream/createReadableStream.js +1 -0
  6. package/dist/cjs/core/server/stream/createReadableStream.worker.js +1 -0
  7. package/dist/cjs/core/server/stream/shared.js +4 -0
  8. package/dist/cjs/core/server/string/loadable.js +4 -4
  9. package/dist/cjs/router/cli/code/nestedRoutes.js +1 -2
  10. package/dist/cjs/router/cli/code/templates.js +1 -1
  11. package/dist/cjs/router/cli/code/utils.js +2 -2
  12. package/dist/cjs/router/runtime/DeferredDataScripts.node.js +10 -9
  13. package/dist/cjs/router/runtime/plugin.node.js +1 -1
  14. package/dist/esm/cli/template.server.mjs +1 -2
  15. package/dist/esm/core/browser/hydrate.mjs +2 -2
  16. package/dist/esm/core/server/stream/beforeTemplate.mjs +3 -3
  17. package/dist/esm/core/server/stream/beforeTemplate.worker.mjs +2 -2
  18. package/dist/esm/core/server/stream/createReadableStream.mjs +2 -1
  19. package/dist/esm/core/server/stream/createReadableStream.worker.mjs +2 -1
  20. package/dist/esm/core/server/stream/shared.mjs +2 -1
  21. package/dist/esm/core/server/string/loadable.mjs +4 -4
  22. package/dist/esm/router/cli/code/nestedRoutes.mjs +1 -2
  23. package/dist/esm/router/cli/code/templates.mjs +1 -1
  24. package/dist/esm/router/cli/code/utils.mjs +2 -2
  25. package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +10 -9
  26. package/dist/esm/router/runtime/plugin.node.mjs +1 -1
  27. package/dist/esm-node/cli/template.server.mjs +1 -2
  28. package/dist/esm-node/core/browser/hydrate.mjs +2 -2
  29. package/dist/esm-node/core/server/stream/beforeTemplate.mjs +3 -3
  30. package/dist/esm-node/core/server/stream/beforeTemplate.worker.mjs +2 -2
  31. package/dist/esm-node/core/server/stream/createReadableStream.mjs +2 -1
  32. package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +2 -1
  33. package/dist/esm-node/core/server/stream/shared.mjs +2 -1
  34. package/dist/esm-node/core/server/string/loadable.mjs +4 -4
  35. package/dist/esm-node/router/cli/code/nestedRoutes.mjs +1 -2
  36. package/dist/esm-node/router/cli/code/templates.mjs +1 -1
  37. package/dist/esm-node/router/cli/code/utils.mjs +2 -2
  38. package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +10 -9
  39. package/dist/esm-node/router/runtime/plugin.node.mjs +1 -1
  40. package/dist/types/core/server/stream/shared.d.ts +9 -0
  41. 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;
@@ -245,6 +245,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
245
245
  reactStream = renderToPipeableStream(processedRootElement, {
246
246
  nonce: config.nonce,
247
247
  identifierPrefix: constants_namespaceObject.SSR_HYDRATION_ID_PREFIX,
248
+ progressiveChunkSize: external_shared_js_namespaceObject_1.SHELL_PROGRESSIVE_CHUNK_SIZE,
248
249
  [onReady] () {
249
250
  startOutput().catch(fail);
250
251
  },
@@ -93,6 +93,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
93
93
  request,
94
94
  signal: request.signal,
95
95
  nonce: config.nonce,
96
+ progressiveChunkSize: external_shared_js_namespaceObject_1.SHELL_PROGRESSIVE_CHUNK_SIZE,
96
97
  rscManifest,
97
98
  rscRoot: rscRoot,
98
99
  routes: runtimeContext.routes,
@@ -28,6 +28,7 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
+ SHELL_PROGRESSIVE_CHUNK_SIZE: ()=>SHELL_PROGRESSIVE_CHUNK_SIZE,
31
32
  ShellChunkStatus: ()=>shared_ShellChunkStatus,
32
33
  createRenderStreaming: ()=>createRenderStreaming,
33
34
  encodeForWebStream: ()=>encodeForWebStream,
@@ -46,6 +47,7 @@ var shared_ShellChunkStatus = /*#__PURE__*/ function(ShellChunkStatus) {
46
47
  ShellChunkStatus[ShellChunkStatus["FINISH"] = 1] = "FINISH";
47
48
  return ShellChunkStatus;
48
49
  }({});
50
+ const SHELL_PROGRESSIVE_CHUNK_SIZE = Number.MAX_SAFE_INTEGER;
49
51
  const SHOULD_STREAM_ALL_HEADER = 'x-should-stream-all';
50
52
  function parseShouldStreamAllFlag(value) {
51
53
  if (!value) return;
@@ -143,12 +145,14 @@ function createRenderStreaming(createReadableStreamPromise) {
143
145
  return stream;
144
146
  };
145
147
  }
148
+ exports.SHELL_PROGRESSIVE_CHUNK_SIZE = __webpack_exports__.SHELL_PROGRESSIVE_CHUNK_SIZE;
146
149
  exports.ShellChunkStatus = __webpack_exports__.ShellChunkStatus;
147
150
  exports.createRenderStreaming = __webpack_exports__.createRenderStreaming;
148
151
  exports.encodeForWebStream = __webpack_exports__.encodeForWebStream;
149
152
  exports.getReadableStreamFromString = __webpack_exports__.getReadableStreamFromString;
150
153
  exports.resolveStreamingMode = __webpack_exports__.resolveStreamingMode;
151
154
  for(var __rspack_i in __webpack_exports__)if (-1 === [
155
+ "SHELL_PROGRESSIVE_CHUNK_SIZE",
152
156
  "ShellChunkStatus",
153
157
  "createRenderStreaming",
154
158
  "encodeForWebStream",
@@ -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 = {
@@ -422,7 +422,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
422
422
  enableRsc: true,
423
423
  });
424
424
  `;
425
- return `${imports.join('\n')}
425
+ else return `${imports.join('\n')}
426
426
 
427
427
  import { routes } from '${routesImportPath}';
428
428
 
@@ -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;
@@ -9,7 +9,7 @@ import { wrapRuntimeComponentResolver } from "../../react/wrapper.mjs";
9
9
  import { createReplaceHelemt, getHelmetData } from "../helmet.mjs";
10
10
  import { createSSRRenderLifecycle, createSSRStreamErrorReporter, observeSSRStream, orderSSRStreamTransforms } from "../shared.mjs";
11
11
  import { enqueueFromEntries } from "./deferredScript.mjs";
12
- import { ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
12
+ import { SHELL_PROGRESSIVE_CHUNK_SIZE, ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
13
13
  import { getTemplates } from "./template.mjs";
14
14
  const createReadableStreamFromElement = async (request, rootElement, options)=>{
15
15
  const { renderToPipeableStream } = await import("react-dom/server");
@@ -213,6 +213,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
213
213
  reactStream = renderToPipeableStream(processedRootElement, {
214
214
  nonce: config.nonce,
215
215
  identifierPrefix: SSR_HYDRATION_ID_PREFIX,
216
+ progressiveChunkSize: SHELL_PROGRESSIVE_CHUNK_SIZE,
216
217
  [onReady] () {
217
218
  startOutput().catch(fail);
218
219
  },
@@ -8,7 +8,7 @@ import { wrapRuntimeComponentResolver } from "../../react/wrapper.mjs";
8
8
  import { createReplaceHelemt, getHelmetData } from "../helmet.mjs";
9
9
  import { createSSRRenderLifecycle, createSSRStreamErrorReporter, observeSSRStream, orderSSRStreamTransforms } from "../shared.mjs";
10
10
  import { enqueueFromEntries } from "./deferredScript.mjs";
11
- import { ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
11
+ import { SHELL_PROGRESSIVE_CHUNK_SIZE, ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
12
12
  import { getTemplates } from "./template.mjs";
13
13
  const createReadableStreamFromElement = async (request, rootElement, options)=>{
14
14
  const { htmlTemplate, runtimeContext, config, ssrConfig, entryName, resource, rscManifest, rscRoot } = options;
@@ -51,6 +51,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
51
51
  request,
52
52
  signal: request.signal,
53
53
  nonce: config.nonce,
54
+ progressiveChunkSize: SHELL_PROGRESSIVE_CHUNK_SIZE,
54
55
  rscManifest,
55
56
  rscRoot: rscRoot,
56
57
  routes: runtimeContext.routes,
@@ -10,6 +10,7 @@ var shared_ShellChunkStatus = /*#__PURE__*/ function(ShellChunkStatus) {
10
10
  ShellChunkStatus[ShellChunkStatus["FINISH"] = 1] = "FINISH";
11
11
  return ShellChunkStatus;
12
12
  }({});
13
+ const SHELL_PROGRESSIVE_CHUNK_SIZE = Number.MAX_SAFE_INTEGER;
13
14
  const SHOULD_STREAM_ALL_HEADER = 'x-should-stream-all';
14
15
  function parseShouldStreamAllFlag(value) {
15
16
  if (!value) return;
@@ -107,4 +108,4 @@ function createRenderStreaming(createReadableStreamPromise) {
107
108
  return stream;
108
109
  };
109
110
  }
110
- export { createRenderStreaming, encodeForWebStream, getReadableStreamFromString, resolveStreamingMode, shared_ShellChunkStatus as ShellChunkStatus };
111
+ export { SHELL_PROGRESSIVE_CHUNK_SIZE, createRenderStreaming, encodeForWebStream, getReadableStreamFromString, resolveStreamingMode, shared_ShellChunkStatus as ShellChunkStatus };
@@ -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 = {
@@ -377,7 +377,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
377
377
  enableRsc: true,
378
378
  });
379
379
  `;
380
- return `${imports.join('\n')}
380
+ else return `${imports.join('\n')}
381
381
 
382
382
  import { routes } from '${routesImportPath}';
383
383
 
@@ -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;
@@ -10,7 +10,7 @@ import { wrapRuntimeComponentResolver } from "../../react/wrapper.mjs";
10
10
  import { createReplaceHelemt, getHelmetData } from "../helmet.mjs";
11
11
  import { createSSRRenderLifecycle, createSSRStreamErrorReporter, observeSSRStream, orderSSRStreamTransforms } from "../shared.mjs";
12
12
  import { enqueueFromEntries } from "./deferredScript.mjs";
13
- import { ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
13
+ import { SHELL_PROGRESSIVE_CHUNK_SIZE, ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
14
14
  import { getTemplates } from "./template.mjs";
15
15
  const createReadableStreamFromElement = async (request, rootElement, options)=>{
16
16
  const { renderToPipeableStream } = await import("react-dom/server");
@@ -214,6 +214,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
214
214
  reactStream = renderToPipeableStream(processedRootElement, {
215
215
  nonce: config.nonce,
216
216
  identifierPrefix: SSR_HYDRATION_ID_PREFIX,
217
+ progressiveChunkSize: SHELL_PROGRESSIVE_CHUNK_SIZE,
217
218
  [onReady] () {
218
219
  startOutput().catch(fail);
219
220
  },
@@ -9,7 +9,7 @@ import { wrapRuntimeComponentResolver } from "../../react/wrapper.mjs";
9
9
  import { createReplaceHelemt, getHelmetData } from "../helmet.mjs";
10
10
  import { createSSRRenderLifecycle, createSSRStreamErrorReporter, observeSSRStream, orderSSRStreamTransforms } from "../shared.mjs";
11
11
  import { enqueueFromEntries } from "./deferredScript.mjs";
12
- import { ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
12
+ import { SHELL_PROGRESSIVE_CHUNK_SIZE, ShellChunkStatus, getReadableStreamFromString, resolveStreamingMode } from "./shared.mjs";
13
13
  import { getTemplates } from "./template.mjs";
14
14
  const createReadableStreamFromElement = async (request, rootElement, options)=>{
15
15
  const { htmlTemplate, runtimeContext, config, ssrConfig, entryName, resource, rscManifest, rscRoot } = options;
@@ -52,6 +52,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
52
52
  request,
53
53
  signal: request.signal,
54
54
  nonce: config.nonce,
55
+ progressiveChunkSize: SHELL_PROGRESSIVE_CHUNK_SIZE,
55
56
  rscManifest,
56
57
  rscRoot: rscRoot,
57
58
  routes: runtimeContext.routes,
@@ -11,6 +11,7 @@ var shared_ShellChunkStatus = /*#__PURE__*/ function(ShellChunkStatus) {
11
11
  ShellChunkStatus[ShellChunkStatus["FINISH"] = 1] = "FINISH";
12
12
  return ShellChunkStatus;
13
13
  }({});
14
+ const SHELL_PROGRESSIVE_CHUNK_SIZE = Number.MAX_SAFE_INTEGER;
14
15
  const SHOULD_STREAM_ALL_HEADER = 'x-should-stream-all';
15
16
  function parseShouldStreamAllFlag(value) {
16
17
  if (!value) return;
@@ -108,4 +109,4 @@ function createRenderStreaming(createReadableStreamPromise) {
108
109
  return stream;
109
110
  };
110
111
  }
111
- export { createRenderStreaming, encodeForWebStream, getReadableStreamFromString, resolveStreamingMode, shared_ShellChunkStatus as ShellChunkStatus };
112
+ export { SHELL_PROGRESSIVE_CHUNK_SIZE, createRenderStreaming, encodeForWebStream, getReadableStreamFromString, resolveStreamingMode, shared_ShellChunkStatus as ShellChunkStatus };
@@ -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 = {
@@ -379,7 +379,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
379
379
  enableRsc: true,
380
380
  });
381
381
  `;
382
- return `${imports.join('\n')}
382
+ else return `${imports.join('\n')}
383
383
 
384
384
  import { routes } from '${routesImportPath}';
385
385
 
@@ -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, {
@@ -32,6 +32,15 @@ export declare enum ShellChunkStatus {
32
32
  START = 0,
33
33
  FINISH = 1
34
34
  }
35
+ /**
36
+ * The document head is sealed when the shell end mark is written, so only head
37
+ * tags emitted before it reach `<head>`. React writes a completed Suspense
38
+ * boundary after the shell once the flushed bytes exceed `progressiveChunkSize`,
39
+ * which drops the head of every large route and keeps its content hidden until
40
+ * the inline `$RC` script runs. Completed boundaries therefore stay inline in
41
+ * the shell; pending boundaries still stream when they resolve.
42
+ */
43
+ export declare const SHELL_PROGRESSIVE_CHUNK_SIZE: number;
35
44
  export declare function resolveStreamingMode(request: Request, forceStreamToString: boolean): {
36
45
  onReady: 'onAllReady' | 'onShellReady';
37
46
  waitForAllReady: boolean;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.0-ultramodern.12",
20
+ "version": "3.9.0-ultramodern.14",
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.12",
221
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.12",
222
- "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.0-ultramodern.12",
223
- "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.12",
224
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.12",
225
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.12",
226
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.12",
227
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.12",
220
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.0-ultramodern.14",
221
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.0-ultramodern.14",
222
+ "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.0-ultramodern.14",
223
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.0-ultramodern.14",
224
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.0-ultramodern.14",
225
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.0-ultramodern.14",
226
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.14",
227
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.14",
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.0.0",
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.2.8"
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.12",
248
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.0-ultramodern.14",
249
249
  "@remix-run/web-fetch": "^4.4.2",
250
- "@rsbuild/core": "2.2.3",
251
- "@rslib/core": "1.0.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.1",
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.4.1",
258
+ "@types/node": "^26.6.2",
259
259
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
260
- "react": "^19.2.8",
261
- "react-dom": "^19.2.8",
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
  },