@reckona/mreact-router 0.0.105 → 0.0.107

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reckona/mreact-router",
3
- "version": "0.0.105",
3
+ "version": "0.0.107",
4
4
  "description": "File-system app router, SSR, actions, and deployment adapters for mreact.",
5
5
  "keywords": [
6
6
  "jsx",
@@ -105,20 +105,20 @@
105
105
  },
106
106
  "dependencies": {
107
107
  "typescript": "^6.0.3",
108
- "@reckona/mreact-compat": "0.0.105",
109
- "@reckona/mreact": "0.0.105",
110
- "@reckona/mreact-reactive-core": "0.0.105",
111
- "@reckona/mreact-devtools": "0.0.105",
112
- "@reckona/mreact-query": "0.0.105",
113
- "@reckona/mreact-compiler": "0.0.105",
114
- "@reckona/mreact-reactive-dom": "0.0.105",
115
- "@reckona/mreact-server": "0.0.105",
116
- "@reckona/mreact-shared": "0.0.105"
108
+ "@reckona/mreact-compat": "0.0.107",
109
+ "@reckona/mreact": "0.0.107",
110
+ "@reckona/mreact-devtools": "0.0.107",
111
+ "@reckona/mreact-compiler": "0.0.107",
112
+ "@reckona/mreact-query": "0.0.107",
113
+ "@reckona/mreact-reactive-core": "0.0.107",
114
+ "@reckona/mreact-reactive-dom": "0.0.107",
115
+ "@reckona/mreact-server": "0.0.107",
116
+ "@reckona/mreact-shared": "0.0.107"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "vite": ">=8 <9"
120
120
  },
121
121
  "optionalDependencies": {
122
- "@reckona/mreact-router-native": "0.0.105"
122
+ "@reckona/mreact-router-native": "0.0.107"
123
123
  }
124
124
  }
@@ -328,10 +328,13 @@ export function createCloudflareRouteModuleRenderer<Env = unknown>(
328
328
  const component = selectCloudflarePageComponent(pageModule);
329
329
 
330
330
  if (component === undefined) {
331
- return new Response(`No Cloudflare page component registered for ${context.route.file}.`, {
332
- headers: { "content-type": "text/plain; charset=utf-8" },
333
- status: 500,
334
- });
331
+ return new Response(
332
+ `No Cloudflare page component registered for ${context.route.file}. Module exports: ${describeCloudflareModuleExports(pageModule)}.`,
333
+ {
334
+ headers: { "content-type": "text/plain; charset=utf-8" },
335
+ status: 500,
336
+ },
337
+ );
335
338
  }
336
339
 
337
340
  const loaderContext = {
@@ -470,6 +473,31 @@ function selectCloudflarePageComponent<Data, Env>(
470
473
  return undefined;
471
474
  }
472
475
 
476
+ const cloudflareDiagnosticPageModuleExportNames = ["default", "App", "slots"] as const;
477
+
478
+ // Fixed names + typeof only (never values) so the 500 response is useful without
479
+ // listing app-specific export names. Accessors are not invoked.
480
+ function describeCloudflareModuleExports(module: object): string {
481
+ const described = cloudflareDiagnosticPageModuleExportNames.map(
482
+ (name) => `${name}=${typeofCloudflareModuleExport(module, name)}`,
483
+ );
484
+
485
+ return described.join(", ");
486
+ }
487
+
488
+ function typeofCloudflareModuleExport(module: object, name: string): string {
489
+ const descriptor = Object.getOwnPropertyDescriptor(module, name);
490
+ if (descriptor === undefined) {
491
+ return "absent";
492
+ }
493
+
494
+ if (!("value" in descriptor)) {
495
+ return "accessor";
496
+ }
497
+
498
+ return typeof descriptor.value;
499
+ }
500
+
473
501
  async function dispatchCloudflareMetadataRoute(
474
502
  module: CloudflareMetadataRouteModule,
475
503
  request: Request,
@@ -647,6 +675,7 @@ export function cloudflareClientAssetPaths(
647
675
  route.script,
648
676
  route.sourceMap,
649
677
  route.navigationScript,
678
+ ...(route.css ?? []),
650
679
  ...(route.imports ?? []),
651
680
  ]) {
652
681
  const path = safeClientAssetPath(prefix, asset);
package/src/build.ts CHANGED
@@ -2565,7 +2565,7 @@ async function writeCloudflareRouteModules(options: {
2565
2565
 
2566
2566
  const componentImport = `./${componentFile.split("/").pop() ?? componentFile}`;
2567
2567
  routeModuleExports = [
2568
- `export { default, App, slots } from ${JSON.stringify(componentImport)};`,
2568
+ cloudflarePageRouteFacadeModuleSource(componentImport),
2569
2569
  ];
2570
2570
  } catch (error) {
2571
2571
  throw new Error(
@@ -2608,6 +2608,24 @@ async function writeCloudflareRouteModules(options: {
2608
2608
  return { registryFile: "route-modules.mjs" };
2609
2609
  }
2610
2610
 
2611
+ function cloudflarePageRouteFacadeModuleSource(componentImport: string): string {
2612
+ return `import { default as componentDefault, App as componentApp, slots as componentSlots } from ${JSON.stringify(componentImport)};
2613
+
2614
+ const routeComponent = typeof componentDefault === "function"
2615
+ ? componentDefault
2616
+ : typeof componentApp === "function"
2617
+ ? componentApp
2618
+ : undefined;
2619
+
2620
+ export const App = routeComponent === undefined
2621
+ ? undefined
2622
+ : function CloudflareRouteComponent(props) {
2623
+ return routeComponent(props);
2624
+ };
2625
+ export default App;
2626
+ export const slots = componentSlots === undefined ? undefined : { ...componentSlots };`;
2627
+ }
2628
+
2611
2629
  async function collectCloudflareDirectComponentRoutes(options: {
2612
2630
  requiredRoutes: readonly CloudflareRequiredRoute[];
2613
2631
  routesDir: string;