@bleedingdev/modern-js-runtime 3.5.0-ultramodern.101 → 3.5.0-ultramodern.102

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.
@@ -84,7 +84,7 @@ async function generateRoutesForEntry(entrypoint, appContext) {
84
84
  }
85
85
  return routes;
86
86
  }
87
- const generateCode = async (appContext, config, entrypoints, api)=>{
87
+ const generateCode = async (appContext, config, entrypoints, api, options = {})=>{
88
88
  const { internalDirectory, srcDirectory, internalSrcAlias, packageName } = appContext;
89
89
  const hooks = api.getHooks();
90
90
  const generatedRoutesByEntry = {};
@@ -143,6 +143,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
143
143
  internalDirectory,
144
144
  splitRouteChunks: config?.output?.splitRouteChunks,
145
145
  isRscClientBundle: (0, utils_namespaceObject.isUseRsc)(config),
146
+ hydrateRscClientRoutes: options.hydrateRscClientRoutes,
146
147
  srcDirectory,
147
148
  internalSrcAlias: appContext.internalSrcAlias
148
149
  })
@@ -168,7 +169,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
168
169
  srcDirectory,
169
170
  internalSrcAlias: appContext.internalSrcAlias
170
171
  });
171
- await utils_namespaceObject.fs.outputFile(external_path_default().resolve(internalDirectory, `./${entryName}/routes.server.js`), serverRoutesCode, 'utf8');
172
+ await utils_namespaceObject.fs.outputFile(external_path_default().resolve(internalDirectory, `./${entryName}/${options.serverRoutesFileName || 'routes.server.js'}`), serverRoutesCode, 'utf8');
172
173
  }
173
174
  const serverLoaderCombined = external_templates_js_namespaceObject.ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
174
175
  if (serverLoaderCombined) {
@@ -134,7 +134,7 @@ async function hasUseClientDirective(componentPath, srcDirectory, internalSrcAli
134
134
  await fh?.close();
135
135
  }
136
136
  }
137
- const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true, isRscClientBundle = false, srcDirectory, internalSrcAlias })=>{
137
+ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true, isRscClientBundle = false, hydrateRscClientRoutes = false, srcDirectory, internalSrcAlias })=>{
138
138
  const components = [];
139
139
  const loadings = [];
140
140
  const errors = [];
@@ -206,7 +206,6 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
206
206
  componentPath: route._component,
207
207
  routeId: route.id
208
208
  });
209
- rootLayoutCode = `import RootLayout from '${route._component}'`;
210
209
  component = 'RootLayout';
211
210
  } else if (splitRouteChunks) {
212
211
  lazyImport = createLazyImport({
@@ -227,8 +226,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
227
226
  component = `component_${components.length - 1}`;
228
227
  }
229
228
  const isClientComponent = 'nested' === route.type && Boolean(route._component) && Boolean(srcDirectory) && Boolean(internalSrcAlias) && await hasUseClientDirective(route._component, srcDirectory, internalSrcAlias);
230
- const shouldHydrateRscRoute = isRscClientBundle && !isClientComponent && !route.loader && !route.data;
229
+ const shouldHydrateRscRoute = hydrateRscClientRoutes && isRscClientBundle && !isClientComponent && !route.loader && !route.data;
231
230
  const shouldIncludeClientBundle = !isRscClientBundle || isClientComponent || shouldHydrateRscRoute;
231
+ if (route.isRoot && route._component && shouldIncludeClientBundle) rootLayoutCode = `import RootLayout from '${route._component}'`;
232
232
  const finalRoute = {
233
233
  ...route,
234
234
  loading,
@@ -368,7 +368,7 @@ function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext) {
368
368
  }
369
369
  return null;
370
370
  }
371
- const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType = false, basename })=>{
371
+ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType = false, routesImportPath = './routes', basename })=>{
372
372
  const imports = [
373
373
  `import { setGlobalContext } from '@${metaName}/runtime/context';`
374
374
  ];
@@ -399,7 +399,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
399
399
  const enableRsc = Boolean(rscType);
400
400
  if (isClient) return `${imports.join('\n')}
401
401
 
402
- import { routes } from './routes';
402
+ import { routes } from '${routesImportPath}';
403
403
 
404
404
  const entryName = '${entryName}';
405
405
  const basename = '${basename || '/'}';
@@ -415,7 +415,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
415
415
  `;
416
416
  return `${imports.join('\n')}
417
417
 
418
- import { routes } from './routes';
418
+ import { routes } from '${routesImportPath}';
419
419
 
420
420
  const entryName = '${entryName}';
421
421
  const basename = '${basename || '/'}';
@@ -64,7 +64,10 @@ async function handleGeneratorEntryCode(api, entrypoints, options = {}) {
64
64
  const { generatorRegisterCode, generateCode, generatorServerRegisterCode } = await import("./code/index.js");
65
65
  originEntrypointsByKey.set(entrypointsKey, (0, lodash_namespaceObject.cloneDeep)(entrypoints));
66
66
  const enableRsc = resolvedConfig?.server?.rsc;
67
- const routesByEntry = await generateCode(appContext, resolvedConfig, entrypoints, api);
67
+ const routesByEntry = await generateCode(appContext, resolvedConfig, entrypoints, api, {
68
+ hydrateRscClientRoutes: normalizedOptions.hydrateRscClientRoutes,
69
+ serverRoutesFileName: normalizedOptions.serverRoutesFileName
70
+ });
68
71
  await Promise.all(entrypoints.map(async (entrypoint)=>{
69
72
  if (entrypoint.nestedRoutesEntry || entrypoint.pageRoutesEntry) {
70
73
  const route = appContext.serverRoutes.find((r)=>r.entryName === entrypoint.entryName);
@@ -87,6 +90,7 @@ async function handleGeneratorEntryCode(api, entrypoints, options = {}) {
87
90
  internalSrcAlias: appContext.internalSrcAlias,
88
91
  globalApp: entrypoint.fileSystemRoutes?.globalApp,
89
92
  rscType: 'server',
93
+ routesImportPath: normalizedOptions.serverRoutesFileName ? `./${normalizedOptions.serverRoutesFileName.replace(/\.js$/, '')}` : void 0,
90
94
  basename
91
95
  }));
92
96
  }
@@ -117,18 +117,18 @@ const routerPlugin = (userConfig = {})=>({
117
117
  const { routes } = routerResult;
118
118
  routesContainer.current = routes;
119
119
  beforeCreateRouter = false;
120
- const RouterContent = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
121
- children: [
122
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(router_namespaceObject.RouterProvider, {
123
- router: router
124
- }),
125
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EmptyComponent, {}),
126
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EmptyComponent, {})
127
- ]
128
- });
120
+ const routerContent = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
121
+ children: [
122
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(router_namespaceObject.RouterProvider, {
123
+ router: router
124
+ }),
125
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EmptyComponent, {}),
126
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(EmptyComponent, {})
127
+ ]
128
+ });
129
129
  return App ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(App, {
130
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterContent, {})
131
- }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterContent, {});
130
+ children: routerContent
131
+ }) : routerContent;
132
132
  };
133
133
  return RouterWrapper;
134
134
  });
@@ -39,7 +39,7 @@ async function generateRoutesForEntry(entrypoint, appContext) {
39
39
  }
40
40
  return routes;
41
41
  }
42
- const generateCode = async (appContext, config, entrypoints, api)=>{
42
+ const generateCode = async (appContext, config, entrypoints, api, options = {})=>{
43
43
  const { internalDirectory, srcDirectory, internalSrcAlias, packageName } = appContext;
44
44
  const hooks = api.getHooks();
45
45
  const generatedRoutesByEntry = {};
@@ -98,6 +98,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
98
98
  internalDirectory,
99
99
  splitRouteChunks: config?.output?.splitRouteChunks,
100
100
  isRscClientBundle: isUseRsc(config),
101
+ hydrateRscClientRoutes: options.hydrateRscClientRoutes,
101
102
  srcDirectory,
102
103
  internalSrcAlias: appContext.internalSrcAlias
103
104
  })
@@ -123,7 +124,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
123
124
  srcDirectory,
124
125
  internalSrcAlias: appContext.internalSrcAlias
125
126
  });
126
- await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/routes.server.js`), serverRoutesCode, 'utf8');
127
+ await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/${options.serverRoutesFileName || 'routes.server.js'}`), serverRoutesCode, 'utf8');
127
128
  }
128
129
  const serverLoaderCombined = __rspack_external__templates_mjs_ab577925.ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
129
130
  if (serverLoaderCombined) {
@@ -89,7 +89,7 @@ async function hasUseClientDirective(componentPath, srcDirectory, internalSrcAli
89
89
  await fh?.close();
90
90
  }
91
91
  }
92
- const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true, isRscClientBundle = false, srcDirectory, internalSrcAlias })=>{
92
+ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true, isRscClientBundle = false, hydrateRscClientRoutes = false, srcDirectory, internalSrcAlias })=>{
93
93
  const components = [];
94
94
  const loadings = [];
95
95
  const errors = [];
@@ -161,7 +161,6 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
161
161
  componentPath: route._component,
162
162
  routeId: route.id
163
163
  });
164
- rootLayoutCode = `import RootLayout from '${route._component}'`;
165
164
  component = 'RootLayout';
166
165
  } else if (splitRouteChunks) {
167
166
  lazyImport = createLazyImport({
@@ -182,8 +181,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
182
181
  component = `component_${components.length - 1}`;
183
182
  }
184
183
  const isClientComponent = 'nested' === route.type && Boolean(route._component) && Boolean(srcDirectory) && Boolean(internalSrcAlias) && await hasUseClientDirective(route._component, srcDirectory, internalSrcAlias);
185
- const shouldHydrateRscRoute = isRscClientBundle && !isClientComponent && !route.loader && !route.data;
184
+ const shouldHydrateRscRoute = hydrateRscClientRoutes && isRscClientBundle && !isClientComponent && !route.loader && !route.data;
186
185
  const shouldIncludeClientBundle = !isRscClientBundle || isClientComponent || shouldHydrateRscRoute;
186
+ if (route.isRoot && route._component && shouldIncludeClientBundle) rootLayoutCode = `import RootLayout from '${route._component}'`;
187
187
  const finalRoute = {
188
188
  ...route,
189
189
  loading,
@@ -323,7 +323,7 @@ function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext) {
323
323
  }
324
324
  return null;
325
325
  }
326
- const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType = false, basename })=>{
326
+ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType = false, routesImportPath = './routes', basename })=>{
327
327
  const imports = [
328
328
  `import { setGlobalContext } from '@${metaName}/runtime/context';`
329
329
  ];
@@ -354,7 +354,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
354
354
  const enableRsc = Boolean(rscType);
355
355
  if (isClient) return `${imports.join('\n')}
356
356
 
357
- import { routes } from './routes';
357
+ import { routes } from '${routesImportPath}';
358
358
 
359
359
  const entryName = '${entryName}';
360
360
  const basename = '${basename || '/'}';
@@ -370,7 +370,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
370
370
  `;
371
371
  return `${imports.join('\n')}
372
372
 
373
- import { routes } from './routes';
373
+ import { routes } from '${routesImportPath}';
374
374
 
375
375
  const entryName = '${entryName}';
376
376
  const basename = '${basename || '/'}';
@@ -20,7 +20,10 @@ async function handleGeneratorEntryCode(api, entrypoints, options = {}) {
20
20
  const { generatorRegisterCode, generateCode, generatorServerRegisterCode } = await import("./code/index.mjs");
21
21
  originEntrypointsByKey.set(entrypointsKey, cloneDeep(entrypoints));
22
22
  const enableRsc = resolvedConfig?.server?.rsc;
23
- const routesByEntry = await generateCode(appContext, resolvedConfig, entrypoints, api);
23
+ const routesByEntry = await generateCode(appContext, resolvedConfig, entrypoints, api, {
24
+ hydrateRscClientRoutes: normalizedOptions.hydrateRscClientRoutes,
25
+ serverRoutesFileName: normalizedOptions.serverRoutesFileName
26
+ });
24
27
  await Promise.all(entrypoints.map(async (entrypoint)=>{
25
28
  if (entrypoint.nestedRoutesEntry || entrypoint.pageRoutesEntry) {
26
29
  const route = appContext.serverRoutes.find((r)=>r.entryName === entrypoint.entryName);
@@ -43,6 +46,7 @@ async function handleGeneratorEntryCode(api, entrypoints, options = {}) {
43
46
  internalSrcAlias: appContext.internalSrcAlias,
44
47
  globalApp: entrypoint.fileSystemRoutes?.globalApp,
45
48
  rscType: 'server',
49
+ routesImportPath: normalizedOptions.serverRoutesFileName ? `./${normalizedOptions.serverRoutesFileName.replace(/\.js$/, '')}` : void 0,
46
50
  basename
47
51
  }));
48
52
  }
@@ -82,18 +82,18 @@ const routerPlugin = (userConfig = {})=>({
82
82
  const { routes } = routerResult;
83
83
  routesContainer.current = routes;
84
84
  beforeCreateRouter = false;
85
- const RouterContent = ()=>/*#__PURE__*/ jsxs(Fragment, {
86
- children: [
87
- /*#__PURE__*/ jsx(RouterProvider, {
88
- router: router
89
- }),
90
- /*#__PURE__*/ jsx(EmptyComponent, {}),
91
- /*#__PURE__*/ jsx(EmptyComponent, {})
92
- ]
93
- });
85
+ const routerContent = /*#__PURE__*/ jsxs(Fragment, {
86
+ children: [
87
+ /*#__PURE__*/ jsx(RouterProvider, {
88
+ router: router
89
+ }),
90
+ /*#__PURE__*/ jsx(EmptyComponent, {}),
91
+ /*#__PURE__*/ jsx(EmptyComponent, {})
92
+ ]
93
+ });
94
94
  return App ? /*#__PURE__*/ jsx(App, {
95
- children: /*#__PURE__*/ jsx(RouterContent, {})
96
- }) : /*#__PURE__*/ jsx(RouterContent, {});
95
+ children: routerContent
96
+ }) : routerContent;
97
97
  };
98
98
  return RouterWrapper;
99
99
  });
@@ -40,7 +40,7 @@ async function generateRoutesForEntry(entrypoint, appContext) {
40
40
  }
41
41
  return routes;
42
42
  }
43
- const generateCode = async (appContext, config, entrypoints, api)=>{
43
+ const generateCode = async (appContext, config, entrypoints, api, options = {})=>{
44
44
  const { internalDirectory, srcDirectory, internalSrcAlias, packageName } = appContext;
45
45
  const hooks = api.getHooks();
46
46
  const generatedRoutesByEntry = {};
@@ -99,6 +99,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
99
99
  internalDirectory,
100
100
  splitRouteChunks: config?.output?.splitRouteChunks,
101
101
  isRscClientBundle: isUseRsc(config),
102
+ hydrateRscClientRoutes: options.hydrateRscClientRoutes,
102
103
  srcDirectory,
103
104
  internalSrcAlias: appContext.internalSrcAlias
104
105
  })
@@ -124,7 +125,7 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
124
125
  srcDirectory,
125
126
  internalSrcAlias: appContext.internalSrcAlias
126
127
  });
127
- await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/routes.server.js`), serverRoutesCode, 'utf8');
128
+ await fs.outputFile(path.resolve(internalDirectory, `./${entryName}/${options.serverRoutesFileName || 'routes.server.js'}`), serverRoutesCode, 'utf8');
128
129
  }
129
130
  const serverLoaderCombined = __rspack_external__templates_mjs_ab577925.ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext);
130
131
  if (serverLoaderCombined) {
@@ -91,7 +91,7 @@ async function hasUseClientDirective(componentPath, srcDirectory, internalSrcAli
91
91
  await fh?.close();
92
92
  }
93
93
  }
94
- const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true, isRscClientBundle = false, srcDirectory, internalSrcAlias })=>{
94
+ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks = true, isRscClientBundle = false, hydrateRscClientRoutes = false, srcDirectory, internalSrcAlias })=>{
95
95
  const components = [];
96
96
  const loadings = [];
97
97
  const errors = [];
@@ -163,7 +163,6 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
163
163
  componentPath: route._component,
164
164
  routeId: route.id
165
165
  });
166
- rootLayoutCode = `import RootLayout from '${route._component}'`;
167
166
  component = 'RootLayout';
168
167
  } else if (splitRouteChunks) {
169
168
  lazyImport = createLazyImport({
@@ -184,8 +183,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
184
183
  component = `component_${components.length - 1}`;
185
184
  }
186
185
  const isClientComponent = 'nested' === route.type && Boolean(route._component) && Boolean(srcDirectory) && Boolean(internalSrcAlias) && await hasUseClientDirective(route._component, srcDirectory, internalSrcAlias);
187
- const shouldHydrateRscRoute = isRscClientBundle && !isClientComponent && !route.loader && !route.data;
186
+ const shouldHydrateRscRoute = hydrateRscClientRoutes && isRscClientBundle && !isClientComponent && !route.loader && !route.data;
188
187
  const shouldIncludeClientBundle = !isRscClientBundle || isClientComponent || shouldHydrateRscRoute;
188
+ if (route.isRoot && route._component && shouldIncludeClientBundle) rootLayoutCode = `import RootLayout from '${route._component}'`;
189
189
  const finalRoute = {
190
190
  ...route,
191
191
  loading,
@@ -325,7 +325,7 @@ function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext) {
325
325
  }
326
326
  return null;
327
327
  }
328
- const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType = false, basename })=>{
328
+ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType = false, routesImportPath = './routes', basename })=>{
329
329
  const imports = [
330
330
  `import { setGlobalContext } from '@${metaName}/runtime/context';`
331
331
  ];
@@ -356,7 +356,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
356
356
  const enableRsc = Boolean(rscType);
357
357
  if (isClient) return `${imports.join('\n')}
358
358
 
359
- import { routes } from './routes';
359
+ import { routes } from '${routesImportPath}';
360
360
 
361
361
  const entryName = '${entryName}';
362
362
  const basename = '${basename || '/'}';
@@ -372,7 +372,7 @@ const runtimeGlobalContext = async ({ entryName, metaName, srcDirectory, nestedR
372
372
  `;
373
373
  return `${imports.join('\n')}
374
374
 
375
- import { routes } from './routes';
375
+ import { routes } from '${routesImportPath}';
376
376
 
377
377
  const entryName = '${entryName}';
378
378
  const basename = '${basename || '/'}';
@@ -21,7 +21,10 @@ async function handleGeneratorEntryCode(api, entrypoints, options = {}) {
21
21
  const { generatorRegisterCode, generateCode, generatorServerRegisterCode } = await import("./code/index.mjs");
22
22
  originEntrypointsByKey.set(entrypointsKey, cloneDeep(entrypoints));
23
23
  const enableRsc = resolvedConfig?.server?.rsc;
24
- const routesByEntry = await generateCode(appContext, resolvedConfig, entrypoints, api);
24
+ const routesByEntry = await generateCode(appContext, resolvedConfig, entrypoints, api, {
25
+ hydrateRscClientRoutes: normalizedOptions.hydrateRscClientRoutes,
26
+ serverRoutesFileName: normalizedOptions.serverRoutesFileName
27
+ });
25
28
  await Promise.all(entrypoints.map(async (entrypoint)=>{
26
29
  if (entrypoint.nestedRoutesEntry || entrypoint.pageRoutesEntry) {
27
30
  const route = appContext.serverRoutes.find((r)=>r.entryName === entrypoint.entryName);
@@ -44,6 +47,7 @@ async function handleGeneratorEntryCode(api, entrypoints, options = {}) {
44
47
  internalSrcAlias: appContext.internalSrcAlias,
45
48
  globalApp: entrypoint.fileSystemRoutes?.globalApp,
46
49
  rscType: 'server',
50
+ routesImportPath: normalizedOptions.serverRoutesFileName ? `./${normalizedOptions.serverRoutesFileName.replace(/\.js$/, '')}` : void 0,
47
51
  basename
48
52
  }));
49
53
  }
@@ -83,18 +83,18 @@ const routerPlugin = (userConfig = {})=>({
83
83
  const { routes } = routerResult;
84
84
  routesContainer.current = routes;
85
85
  beforeCreateRouter = false;
86
- const RouterContent = ()=>/*#__PURE__*/ jsxs(Fragment, {
87
- children: [
88
- /*#__PURE__*/ jsx(RouterProvider, {
89
- router: router
90
- }),
91
- /*#__PURE__*/ jsx(EmptyComponent, {}),
92
- /*#__PURE__*/ jsx(EmptyComponent, {})
93
- ]
94
- });
86
+ const routerContent = /*#__PURE__*/ jsxs(Fragment, {
87
+ children: [
88
+ /*#__PURE__*/ jsx(RouterProvider, {
89
+ router: router
90
+ }),
91
+ /*#__PURE__*/ jsx(EmptyComponent, {}),
92
+ /*#__PURE__*/ jsx(EmptyComponent, {})
93
+ ]
94
+ });
95
95
  return App ? /*#__PURE__*/ jsx(App, {
96
- children: /*#__PURE__*/ jsx(RouterContent, {})
97
- }) : /*#__PURE__*/ jsx(RouterContent, {});
96
+ children: routerContent
97
+ }) : routerContent;
98
98
  };
99
99
  return RouterWrapper;
100
100
  });
@@ -5,6 +5,9 @@ import type { Entrypoint, NestedRouteForCli, PageRoute } from '@modern-js/types'
5
5
  * Generate routing information for a single entry point (can be reused by the routes inspect feature)
6
6
  */
7
7
  export declare function generateRoutesForEntry(entrypoint: Entrypoint, appContext: AppToolsContext): Promise<NestedRouteForCli[]>;
8
- export declare const generateCode: (appContext: AppToolsContext, config: AppNormalizedConfig, entrypoints: Entrypoint[], api: CLIPluginAPI<AppTools>) => Promise<Record<string, (NestedRouteForCli | PageRoute)[]>>;
8
+ export declare const generateCode: (appContext: AppToolsContext, config: AppNormalizedConfig, entrypoints: Entrypoint[], api: CLIPluginAPI<AppTools>, options?: {
9
+ hydrateRscClientRoutes?: boolean;
10
+ serverRoutesFileName?: string;
11
+ }) => Promise<Record<string, (NestedRouteForCli | PageRoute)[]>>;
9
12
  export declare function generatorRegisterCode(internalDirectory: string, entryName: string, code: string): void;
10
13
  export declare function generatorServerRegisterCode(internalDirectory: string, entryName: string, code: string): void;
@@ -3,7 +3,7 @@ import type { Entrypoint, NestedRouteForCli, PageRoute, RouteLegacy, SSRMode } f
3
3
  export declare const routesForServer: ({ routesForServerLoaderMatches, }: {
4
4
  routesForServerLoaderMatches: (NestedRouteForCli | PageRoute)[];
5
5
  }) => string;
6
- export declare const fileSystemRoutes: ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks, isRscClientBundle, srcDirectory, internalSrcAlias, }: {
6
+ export declare const fileSystemRoutes: ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks, isRscClientBundle, hydrateRscClientRoutes, srcDirectory, internalSrcAlias, }: {
7
7
  metaName: string;
8
8
  routes: RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
9
9
  ssrMode?: SSRMode;
@@ -12,11 +12,12 @@ export declare const fileSystemRoutes: ({ metaName, routes, ssrMode, nestedRoute
12
12
  internalDirectory: string;
13
13
  splitRouteChunks?: boolean;
14
14
  isRscClientBundle?: boolean;
15
+ hydrateRscClientRoutes?: boolean;
15
16
  srcDirectory?: string;
16
17
  internalSrcAlias?: string;
17
18
  }) => Promise<string>;
18
19
  export declare function ssrLoaderCombinedModule(entrypoints: Entrypoint[], entrypoint: Entrypoint, config: AppNormalizedConfig, appContext: AppToolsContext): string | null;
19
- export declare const runtimeGlobalContext: ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType, basename, }: {
20
+ export declare const runtimeGlobalContext: ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, rscType, routesImportPath, basename, }: {
20
21
  entryName: string;
21
22
  metaName: string;
22
23
  srcDirectory: string;
@@ -24,5 +25,6 @@ export declare const runtimeGlobalContext: ({ entryName, metaName, srcDirectory,
24
25
  internalSrcAlias: string;
25
26
  globalApp?: string | false;
26
27
  rscType?: 'server' | 'client' | false;
28
+ routesImportPath?: string;
27
29
  basename?: string;
28
30
  }) => Promise<string>;
@@ -10,6 +10,8 @@ type RegenerateRoutesFn = (params: {
10
10
  }) => Promise<void>;
11
11
  type HandleGeneratorEntryCodeOptions = {
12
12
  entrypointsKey?: string;
13
+ hydrateRscClientRoutes?: boolean;
14
+ serverRoutesFileName?: string;
13
15
  };
14
16
  type HandleFileChangeOptions = {
15
17
  includeEntry?: (entrypoint: Entrypoint) => boolean;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.5.0-ultramodern.101",
20
+ "version": "3.5.0-ultramodern.102",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -246,12 +246,12 @@
246
246
  "dependencies": {
247
247
  "@loadable/component": "5.16.7",
248
248
  "@loadable/server": "5.16.7",
249
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.101",
250
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.5.0-ultramodern.101",
251
- "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.5.0-ultramodern.101",
252
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.101",
253
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.101",
254
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.101",
249
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.102",
250
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.5.0-ultramodern.102",
251
+ "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.5.0-ultramodern.102",
252
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.102",
253
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.102",
254
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.102",
255
255
  "@swc/core": "1.15.43",
256
256
  "@swc/helpers": "^0.5.23",
257
257
  "@swc/plugin-loadable-components": "^11.15.0",
@@ -272,7 +272,7 @@
272
272
  "react-dom": "^19.2.7"
273
273
  },
274
274
  "devDependencies": {
275
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.101",
275
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.102",
276
276
  "@remix-run/web-fetch": "^4.4.2",
277
277
  "@rsbuild/core": "2.1.5",
278
278
  "@rslib/core": "0.23.2",