@webtypen/webframez-react 0.0.23 → 0.0.25

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.
@@ -6,9 +6,14 @@ const frameworkDistDir = path.resolve(__dirname, "..", "dist");
6
6
  const clientEntry = process.env.WEBFRAMEZ_REACT_CLIENT_ENTRY
7
7
  ? path.resolve(projectRoot, process.env.WEBFRAMEZ_REACT_CLIENT_ENTRY)
8
8
  : path.resolve(projectRoot, "src/client.tsx");
9
+ const isWatchMode = process.argv.includes("--watch");
10
+ const mode =
11
+ process.env.NODE_ENV === "production" || (typeof process.env.NODE_ENV === "undefined" && !isWatchMode)
12
+ ? "production"
13
+ : "development";
9
14
 
10
15
  module.exports = {
11
- mode: process.env.NODE_ENV === "production" ? "production" : "development",
16
+ mode,
12
17
  entry: {
13
18
  client: clientEntry,
14
19
  },
@@ -38,6 +43,8 @@ module.exports = {
38
43
  optimization: {
39
44
  splitChunks: false,
40
45
  runtimeChunk: false,
46
+ moduleIds: "named",
47
+ chunkIds: "named",
41
48
  },
42
49
  plugins: [
43
50
  new ReactFlightWebpackPlugin({
package/dist/http.cjs CHANGED
@@ -409,8 +409,25 @@ function renderHeadToString(head) {
409
409
  }
410
410
  return tags.join("\n");
411
411
  }
412
- function resolveModule(modulePath) {
413
- delete require.cache[modulePath];
412
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
413
+ const resolvedPath = require.resolve(modulePath);
414
+ if (visited.has(resolvedPath)) {
415
+ return;
416
+ }
417
+ visited.add(resolvedPath);
418
+ const cachedModule = require.cache[resolvedPath];
419
+ if (!cachedModule) {
420
+ return;
421
+ }
422
+ for (const child of cachedModule.children) {
423
+ if (child.id.startsWith(rootDir)) {
424
+ clearModuleCache(child.id, rootDir, visited);
425
+ }
426
+ }
427
+ delete require.cache[resolvedPath];
428
+ }
429
+ function resolveModule(modulePath, rootDir) {
430
+ clearModuleCache(modulePath, rootDir);
414
431
  return require(modulePath);
415
432
  }
416
433
  async function resolveHead(candidate, context) {
@@ -497,7 +514,7 @@ function createFileRouter(options) {
497
514
  message,
498
515
  payload
499
516
  };
500
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
517
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
501
518
  if (!import_node_fs.default.existsSync(errorPath)) {
502
519
  const fallback = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
503
520
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: statusCode }),
@@ -511,7 +528,7 @@ function createFileRouter(options) {
511
528
  }
512
529
  };
513
530
  }
514
- const errorModule = resolveModule(errorPath);
531
+ const errorModule = resolveModule(errorPath, pagesDir);
515
532
  const errorNode = await errorModule.default(errorProps);
516
533
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
517
534
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -560,7 +577,10 @@ function createFileRouter(options) {
560
577
  message: `Invalid middleware '${middlewareNames[0]}'`
561
578
  });
562
579
  }
563
- const middlewareModule = resolveModule(middlewaresPath);
580
+ const middlewareModule = resolveModule(
581
+ middlewaresPath,
582
+ pagesDir
583
+ );
564
584
  const registry = middlewareModule.middlewares;
565
585
  if (!registry) {
566
586
  if (!requiresNamedMiddleware) {
@@ -615,8 +635,8 @@ function createFileRouter(options) {
615
635
  params: match.params
616
636
  };
617
637
  activeContext = context;
618
- const pageModule = resolveModule(match.entry.filePath);
619
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
638
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
639
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
620
640
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
621
641
  activeContext = middlewareContext;
622
642
  const pageData = await resolvePageData(pageModule, middlewareContext);
@@ -712,7 +732,21 @@ globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
712
732
  }
713
733
 
714
734
  if (id.startsWith("./")) {
715
- return require(path.resolve(process.cwd(), id.slice(2)));
735
+ const relativeId = id.slice(2);
736
+ const candidates = [
737
+ path.resolve(process.cwd(), relativeId),
738
+ path.resolve(process.cwd(), "..", relativeId)
739
+ ];
740
+ for (const candidate of candidates) {
741
+ try {
742
+ return require(candidate);
743
+ } catch (error) {
744
+ const missingCandidate = error && error.code === "MODULE_NOT_FOUND" && typeof error.message === "string" && error.message.includes("'" + candidate + "'");
745
+ if (!missingCandidate) {
746
+ throw error;
747
+ }
748
+ }
749
+ }
716
750
  }
717
751
 
718
752
  return require(id);
@@ -1016,22 +1050,64 @@ function normalizeClientManifest(manifest, options) {
1016
1050
  }
1017
1051
  function createServerConsumerManifest(manifest) {
1018
1052
  const consumerManifest = {};
1053
+ const normalizeWorkerModuleId = (requestKey, rawModuleId) => {
1054
+ if (typeof rawModuleId === "string" && rawModuleId.trim() !== "") {
1055
+ return rawModuleId;
1056
+ }
1057
+ if (typeof rawModuleId !== "number" || !Number.isFinite(rawModuleId)) {
1058
+ return null;
1059
+ }
1060
+ if (!requestKey || requestKey.trim() === "") {
1061
+ return String(rawModuleId);
1062
+ }
1063
+ if (requestKey.startsWith("file://")) {
1064
+ try {
1065
+ return (0, import_node_url.fileURLToPath)(requestKey);
1066
+ } catch {
1067
+ return String(rawModuleId);
1068
+ }
1069
+ }
1070
+ if (requestKey.startsWith("/")) {
1071
+ return requestKey;
1072
+ }
1073
+ if (requestKey.startsWith("./")) {
1074
+ return requestKey;
1075
+ }
1076
+ if (requestKey.startsWith("node_modules/") || requestKey.startsWith("build/")) {
1077
+ return `./${requestKey}`;
1078
+ }
1079
+ return requestKey;
1080
+ };
1081
+ const addReference = (lookupKey, reference) => {
1082
+ if (!lookupKey || lookupKey.trim() === "") {
1083
+ return;
1084
+ }
1085
+ if (lookupKey in consumerManifest) {
1086
+ return;
1087
+ }
1088
+ consumerManifest[lookupKey] = {
1089
+ "*": reference
1090
+ };
1091
+ };
1019
1092
  for (const [key, value] of Object.entries(manifest)) {
1020
1093
  if (!value || typeof value !== "object") {
1021
1094
  continue;
1022
1095
  }
1023
1096
  const entry = value;
1024
- if (typeof entry.id !== "string" || entry.id.trim() === "") {
1097
+ const workerModuleId = normalizeWorkerModuleId(key, entry.id);
1098
+ if (!workerModuleId) {
1025
1099
  continue;
1026
1100
  }
1027
- consumerManifest[key] = {
1028
- "*": {
1029
- id: entry.id,
1030
- chunks: [],
1031
- name: entry.name ?? "*",
1032
- ...entry.async ? { async: entry.async } : {}
1033
- }
1101
+ const reference = {
1102
+ id: workerModuleId,
1103
+ chunks: Array.isArray(entry.chunks) ? entry.chunks : [],
1104
+ name: entry.name ?? "*",
1105
+ ...entry.async ? { async: entry.async } : {}
1034
1106
  };
1107
+ addReference(key, reference);
1108
+ if (typeof entry.id === "number" && Number.isFinite(entry.id)) {
1109
+ addReference(String(entry.id), reference);
1110
+ }
1035
1111
  }
1036
1112
  return consumerManifest;
1037
1113
  }
package/dist/http.js CHANGED
@@ -384,8 +384,25 @@ function renderHeadToString(head) {
384
384
  }
385
385
  return tags.join("\n");
386
386
  }
387
- function resolveModule(modulePath) {
388
- delete __require.cache[modulePath];
387
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
388
+ const resolvedPath = __require.resolve(modulePath);
389
+ if (visited.has(resolvedPath)) {
390
+ return;
391
+ }
392
+ visited.add(resolvedPath);
393
+ const cachedModule = __require.cache[resolvedPath];
394
+ if (!cachedModule) {
395
+ return;
396
+ }
397
+ for (const child of cachedModule.children) {
398
+ if (child.id.startsWith(rootDir)) {
399
+ clearModuleCache(child.id, rootDir, visited);
400
+ }
401
+ }
402
+ delete __require.cache[resolvedPath];
403
+ }
404
+ function resolveModule(modulePath, rootDir) {
405
+ clearModuleCache(modulePath, rootDir);
389
406
  return __require(modulePath);
390
407
  }
391
408
  async function resolveHead(candidate, context) {
@@ -472,7 +489,7 @@ function createFileRouter(options) {
472
489
  message,
473
490
  payload
474
491
  };
475
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
492
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
476
493
  if (!fs.existsSync(errorPath)) {
477
494
  const fallback = /* @__PURE__ */ jsxs("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
478
495
  /* @__PURE__ */ jsx("h1", { children: statusCode }),
@@ -486,7 +503,7 @@ function createFileRouter(options) {
486
503
  }
487
504
  };
488
505
  }
489
- const errorModule = resolveModule(errorPath);
506
+ const errorModule = resolveModule(errorPath, pagesDir);
490
507
  const errorNode = await errorModule.default(errorProps);
491
508
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
492
509
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -535,7 +552,10 @@ function createFileRouter(options) {
535
552
  message: `Invalid middleware '${middlewareNames[0]}'`
536
553
  });
537
554
  }
538
- const middlewareModule = resolveModule(middlewaresPath);
555
+ const middlewareModule = resolveModule(
556
+ middlewaresPath,
557
+ pagesDir
558
+ );
539
559
  const registry = middlewareModule.middlewares;
540
560
  if (!registry) {
541
561
  if (!requiresNamedMiddleware) {
@@ -590,8 +610,8 @@ function createFileRouter(options) {
590
610
  params: match.params
591
611
  };
592
612
  activeContext = context;
593
- const pageModule = resolveModule(match.entry.filePath);
594
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
613
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
614
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
595
615
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
596
616
  activeContext = middlewareContext;
597
617
  const pageData = await resolvePageData(pageModule, middlewareContext);
@@ -687,7 +707,21 @@ globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
687
707
  }
688
708
 
689
709
  if (id.startsWith("./")) {
690
- return require(path.resolve(process.cwd(), id.slice(2)));
710
+ const relativeId = id.slice(2);
711
+ const candidates = [
712
+ path.resolve(process.cwd(), relativeId),
713
+ path.resolve(process.cwd(), "..", relativeId)
714
+ ];
715
+ for (const candidate of candidates) {
716
+ try {
717
+ return require(candidate);
718
+ } catch (error) {
719
+ const missingCandidate = error && error.code === "MODULE_NOT_FOUND" && typeof error.message === "string" && error.message.includes("'" + candidate + "'");
720
+ if (!missingCandidate) {
721
+ throw error;
722
+ }
723
+ }
724
+ }
691
725
  }
692
726
 
693
727
  return require(id);
@@ -991,22 +1025,64 @@ function normalizeClientManifest(manifest, options) {
991
1025
  }
992
1026
  function createServerConsumerManifest(manifest) {
993
1027
  const consumerManifest = {};
1028
+ const normalizeWorkerModuleId = (requestKey, rawModuleId) => {
1029
+ if (typeof rawModuleId === "string" && rawModuleId.trim() !== "") {
1030
+ return rawModuleId;
1031
+ }
1032
+ if (typeof rawModuleId !== "number" || !Number.isFinite(rawModuleId)) {
1033
+ return null;
1034
+ }
1035
+ if (!requestKey || requestKey.trim() === "") {
1036
+ return String(rawModuleId);
1037
+ }
1038
+ if (requestKey.startsWith("file://")) {
1039
+ try {
1040
+ return fileURLToPath(requestKey);
1041
+ } catch {
1042
+ return String(rawModuleId);
1043
+ }
1044
+ }
1045
+ if (requestKey.startsWith("/")) {
1046
+ return requestKey;
1047
+ }
1048
+ if (requestKey.startsWith("./")) {
1049
+ return requestKey;
1050
+ }
1051
+ if (requestKey.startsWith("node_modules/") || requestKey.startsWith("build/")) {
1052
+ return `./${requestKey}`;
1053
+ }
1054
+ return requestKey;
1055
+ };
1056
+ const addReference = (lookupKey, reference) => {
1057
+ if (!lookupKey || lookupKey.trim() === "") {
1058
+ return;
1059
+ }
1060
+ if (lookupKey in consumerManifest) {
1061
+ return;
1062
+ }
1063
+ consumerManifest[lookupKey] = {
1064
+ "*": reference
1065
+ };
1066
+ };
994
1067
  for (const [key, value] of Object.entries(manifest)) {
995
1068
  if (!value || typeof value !== "object") {
996
1069
  continue;
997
1070
  }
998
1071
  const entry = value;
999
- if (typeof entry.id !== "string" || entry.id.trim() === "") {
1072
+ const workerModuleId = normalizeWorkerModuleId(key, entry.id);
1073
+ if (!workerModuleId) {
1000
1074
  continue;
1001
1075
  }
1002
- consumerManifest[key] = {
1003
- "*": {
1004
- id: entry.id,
1005
- chunks: [],
1006
- name: entry.name ?? "*",
1007
- ...entry.async ? { async: entry.async } : {}
1008
- }
1076
+ const reference = {
1077
+ id: workerModuleId,
1078
+ chunks: Array.isArray(entry.chunks) ? entry.chunks : [],
1079
+ name: entry.name ?? "*",
1080
+ ...entry.async ? { async: entry.async } : {}
1009
1081
  };
1082
+ addReference(key, reference);
1083
+ if (typeof entry.id === "number" && Number.isFinite(entry.id)) {
1084
+ addReference(String(entry.id), reference);
1085
+ }
1010
1086
  }
1011
1087
  return consumerManifest;
1012
1088
  }
package/dist/index.cjs CHANGED
@@ -442,8 +442,25 @@ function renderHeadToString(head) {
442
442
  }
443
443
  return tags.join("\n");
444
444
  }
445
- function resolveModule(modulePath) {
446
- delete require.cache[modulePath];
445
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
446
+ const resolvedPath = require.resolve(modulePath);
447
+ if (visited.has(resolvedPath)) {
448
+ return;
449
+ }
450
+ visited.add(resolvedPath);
451
+ const cachedModule = require.cache[resolvedPath];
452
+ if (!cachedModule) {
453
+ return;
454
+ }
455
+ for (const child of cachedModule.children) {
456
+ if (child.id.startsWith(rootDir)) {
457
+ clearModuleCache(child.id, rootDir, visited);
458
+ }
459
+ }
460
+ delete require.cache[resolvedPath];
461
+ }
462
+ function resolveModule(modulePath, rootDir) {
463
+ clearModuleCache(modulePath, rootDir);
447
464
  return require(modulePath);
448
465
  }
449
466
  async function resolveHead(candidate, context) {
@@ -530,7 +547,7 @@ function createFileRouter(options) {
530
547
  message,
531
548
  payload
532
549
  };
533
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
550
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
534
551
  if (!import_node_fs.default.existsSync(errorPath)) {
535
552
  const fallback = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
536
553
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: statusCode }),
@@ -544,7 +561,7 @@ function createFileRouter(options) {
544
561
  }
545
562
  };
546
563
  }
547
- const errorModule = resolveModule(errorPath);
564
+ const errorModule = resolveModule(errorPath, pagesDir);
548
565
  const errorNode = await errorModule.default(errorProps);
549
566
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
550
567
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -593,7 +610,10 @@ function createFileRouter(options) {
593
610
  message: `Invalid middleware '${middlewareNames[0]}'`
594
611
  });
595
612
  }
596
- const middlewareModule = resolveModule(middlewaresPath);
613
+ const middlewareModule = resolveModule(
614
+ middlewaresPath,
615
+ pagesDir
616
+ );
597
617
  const registry = middlewareModule.middlewares;
598
618
  if (!registry) {
599
619
  if (!requiresNamedMiddleware) {
@@ -648,8 +668,8 @@ function createFileRouter(options) {
648
668
  params: match.params
649
669
  };
650
670
  activeContext = context;
651
- const pageModule = resolveModule(match.entry.filePath);
652
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
671
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
672
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
653
673
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
654
674
  activeContext = middlewareContext;
655
675
  const pageData = await resolvePageData(pageModule, middlewareContext);
@@ -749,7 +769,21 @@ globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
749
769
  }
750
770
 
751
771
  if (id.startsWith("./")) {
752
- return require(path.resolve(process.cwd(), id.slice(2)));
772
+ const relativeId = id.slice(2);
773
+ const candidates = [
774
+ path.resolve(process.cwd(), relativeId),
775
+ path.resolve(process.cwd(), "..", relativeId)
776
+ ];
777
+ for (const candidate of candidates) {
778
+ try {
779
+ return require(candidate);
780
+ } catch (error) {
781
+ const missingCandidate = error && error.code === "MODULE_NOT_FOUND" && typeof error.message === "string" && error.message.includes("'" + candidate + "'");
782
+ if (!missingCandidate) {
783
+ throw error;
784
+ }
785
+ }
786
+ }
753
787
  }
754
788
 
755
789
  return require(id);
@@ -1053,22 +1087,64 @@ function normalizeClientManifest(manifest, options) {
1053
1087
  }
1054
1088
  function createServerConsumerManifest(manifest) {
1055
1089
  const consumerManifest = {};
1090
+ const normalizeWorkerModuleId = (requestKey, rawModuleId) => {
1091
+ if (typeof rawModuleId === "string" && rawModuleId.trim() !== "") {
1092
+ return rawModuleId;
1093
+ }
1094
+ if (typeof rawModuleId !== "number" || !Number.isFinite(rawModuleId)) {
1095
+ return null;
1096
+ }
1097
+ if (!requestKey || requestKey.trim() === "") {
1098
+ return String(rawModuleId);
1099
+ }
1100
+ if (requestKey.startsWith("file://")) {
1101
+ try {
1102
+ return (0, import_node_url.fileURLToPath)(requestKey);
1103
+ } catch {
1104
+ return String(rawModuleId);
1105
+ }
1106
+ }
1107
+ if (requestKey.startsWith("/")) {
1108
+ return requestKey;
1109
+ }
1110
+ if (requestKey.startsWith("./")) {
1111
+ return requestKey;
1112
+ }
1113
+ if (requestKey.startsWith("node_modules/") || requestKey.startsWith("build/")) {
1114
+ return `./${requestKey}`;
1115
+ }
1116
+ return requestKey;
1117
+ };
1118
+ const addReference = (lookupKey, reference) => {
1119
+ if (!lookupKey || lookupKey.trim() === "") {
1120
+ return;
1121
+ }
1122
+ if (lookupKey in consumerManifest) {
1123
+ return;
1124
+ }
1125
+ consumerManifest[lookupKey] = {
1126
+ "*": reference
1127
+ };
1128
+ };
1056
1129
  for (const [key, value] of Object.entries(manifest)) {
1057
1130
  if (!value || typeof value !== "object") {
1058
1131
  continue;
1059
1132
  }
1060
1133
  const entry = value;
1061
- if (typeof entry.id !== "string" || entry.id.trim() === "") {
1134
+ const workerModuleId = normalizeWorkerModuleId(key, entry.id);
1135
+ if (!workerModuleId) {
1062
1136
  continue;
1063
1137
  }
1064
- consumerManifest[key] = {
1065
- "*": {
1066
- id: entry.id,
1067
- chunks: [],
1068
- name: entry.name ?? "*",
1069
- ...entry.async ? { async: entry.async } : {}
1070
- }
1138
+ const reference = {
1139
+ id: workerModuleId,
1140
+ chunks: Array.isArray(entry.chunks) ? entry.chunks : [],
1141
+ name: entry.name ?? "*",
1142
+ ...entry.async ? { async: entry.async } : {}
1071
1143
  };
1144
+ addReference(key, reference);
1145
+ if (typeof entry.id === "number" && Number.isFinite(entry.id)) {
1146
+ addReference(String(entry.id), reference);
1147
+ }
1072
1148
  }
1073
1149
  return consumerManifest;
1074
1150
  }
package/dist/index.js CHANGED
@@ -406,8 +406,25 @@ function renderHeadToString(head) {
406
406
  }
407
407
  return tags.join("\n");
408
408
  }
409
- function resolveModule(modulePath) {
410
- delete __require.cache[modulePath];
409
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
410
+ const resolvedPath = __require.resolve(modulePath);
411
+ if (visited.has(resolvedPath)) {
412
+ return;
413
+ }
414
+ visited.add(resolvedPath);
415
+ const cachedModule = __require.cache[resolvedPath];
416
+ if (!cachedModule) {
417
+ return;
418
+ }
419
+ for (const child of cachedModule.children) {
420
+ if (child.id.startsWith(rootDir)) {
421
+ clearModuleCache(child.id, rootDir, visited);
422
+ }
423
+ }
424
+ delete __require.cache[resolvedPath];
425
+ }
426
+ function resolveModule(modulePath, rootDir) {
427
+ clearModuleCache(modulePath, rootDir);
411
428
  return __require(modulePath);
412
429
  }
413
430
  async function resolveHead(candidate, context) {
@@ -494,7 +511,7 @@ function createFileRouter(options) {
494
511
  message,
495
512
  payload
496
513
  };
497
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
514
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
498
515
  if (!fs.existsSync(errorPath)) {
499
516
  const fallback = /* @__PURE__ */ jsxs("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
500
517
  /* @__PURE__ */ jsx("h1", { children: statusCode }),
@@ -508,7 +525,7 @@ function createFileRouter(options) {
508
525
  }
509
526
  };
510
527
  }
511
- const errorModule = resolveModule(errorPath);
528
+ const errorModule = resolveModule(errorPath, pagesDir);
512
529
  const errorNode = await errorModule.default(errorProps);
513
530
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
514
531
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -557,7 +574,10 @@ function createFileRouter(options) {
557
574
  message: `Invalid middleware '${middlewareNames[0]}'`
558
575
  });
559
576
  }
560
- const middlewareModule = resolveModule(middlewaresPath);
577
+ const middlewareModule = resolveModule(
578
+ middlewaresPath,
579
+ pagesDir
580
+ );
561
581
  const registry = middlewareModule.middlewares;
562
582
  if (!registry) {
563
583
  if (!requiresNamedMiddleware) {
@@ -612,8 +632,8 @@ function createFileRouter(options) {
612
632
  params: match.params
613
633
  };
614
634
  activeContext = context;
615
- const pageModule = resolveModule(match.entry.filePath);
616
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
635
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
636
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
617
637
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
618
638
  activeContext = middlewareContext;
619
639
  const pageData = await resolvePageData(pageModule, middlewareContext);
@@ -713,7 +733,21 @@ globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
713
733
  }
714
734
 
715
735
  if (id.startsWith("./")) {
716
- return require(path.resolve(process.cwd(), id.slice(2)));
736
+ const relativeId = id.slice(2);
737
+ const candidates = [
738
+ path.resolve(process.cwd(), relativeId),
739
+ path.resolve(process.cwd(), "..", relativeId)
740
+ ];
741
+ for (const candidate of candidates) {
742
+ try {
743
+ return require(candidate);
744
+ } catch (error) {
745
+ const missingCandidate = error && error.code === "MODULE_NOT_FOUND" && typeof error.message === "string" && error.message.includes("'" + candidate + "'");
746
+ if (!missingCandidate) {
747
+ throw error;
748
+ }
749
+ }
750
+ }
717
751
  }
718
752
 
719
753
  return require(id);
@@ -1017,22 +1051,64 @@ function normalizeClientManifest(manifest, options) {
1017
1051
  }
1018
1052
  function createServerConsumerManifest(manifest) {
1019
1053
  const consumerManifest = {};
1054
+ const normalizeWorkerModuleId = (requestKey, rawModuleId) => {
1055
+ if (typeof rawModuleId === "string" && rawModuleId.trim() !== "") {
1056
+ return rawModuleId;
1057
+ }
1058
+ if (typeof rawModuleId !== "number" || !Number.isFinite(rawModuleId)) {
1059
+ return null;
1060
+ }
1061
+ if (!requestKey || requestKey.trim() === "") {
1062
+ return String(rawModuleId);
1063
+ }
1064
+ if (requestKey.startsWith("file://")) {
1065
+ try {
1066
+ return fileURLToPath(requestKey);
1067
+ } catch {
1068
+ return String(rawModuleId);
1069
+ }
1070
+ }
1071
+ if (requestKey.startsWith("/")) {
1072
+ return requestKey;
1073
+ }
1074
+ if (requestKey.startsWith("./")) {
1075
+ return requestKey;
1076
+ }
1077
+ if (requestKey.startsWith("node_modules/") || requestKey.startsWith("build/")) {
1078
+ return `./${requestKey}`;
1079
+ }
1080
+ return requestKey;
1081
+ };
1082
+ const addReference = (lookupKey, reference) => {
1083
+ if (!lookupKey || lookupKey.trim() === "") {
1084
+ return;
1085
+ }
1086
+ if (lookupKey in consumerManifest) {
1087
+ return;
1088
+ }
1089
+ consumerManifest[lookupKey] = {
1090
+ "*": reference
1091
+ };
1092
+ };
1020
1093
  for (const [key, value] of Object.entries(manifest)) {
1021
1094
  if (!value || typeof value !== "object") {
1022
1095
  continue;
1023
1096
  }
1024
1097
  const entry = value;
1025
- if (typeof entry.id !== "string" || entry.id.trim() === "") {
1098
+ const workerModuleId = normalizeWorkerModuleId(key, entry.id);
1099
+ if (!workerModuleId) {
1026
1100
  continue;
1027
1101
  }
1028
- consumerManifest[key] = {
1029
- "*": {
1030
- id: entry.id,
1031
- chunks: [],
1032
- name: entry.name ?? "*",
1033
- ...entry.async ? { async: entry.async } : {}
1034
- }
1102
+ const reference = {
1103
+ id: workerModuleId,
1104
+ chunks: Array.isArray(entry.chunks) ? entry.chunks : [],
1105
+ name: entry.name ?? "*",
1106
+ ...entry.async ? { async: entry.async } : {}
1035
1107
  };
1108
+ addReference(key, reference);
1109
+ if (typeof entry.id === "number" && Number.isFinite(entry.id)) {
1110
+ addReference(String(entry.id), reference);
1111
+ }
1036
1112
  }
1037
1113
  return consumerManifest;
1038
1114
  }
package/dist/router.cjs CHANGED
@@ -300,8 +300,25 @@ function renderHeadToString(head) {
300
300
  }
301
301
  return tags.join("\n");
302
302
  }
303
- function resolveModule(modulePath) {
304
- delete require.cache[modulePath];
303
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
304
+ const resolvedPath = require.resolve(modulePath);
305
+ if (visited.has(resolvedPath)) {
306
+ return;
307
+ }
308
+ visited.add(resolvedPath);
309
+ const cachedModule = require.cache[resolvedPath];
310
+ if (!cachedModule) {
311
+ return;
312
+ }
313
+ for (const child of cachedModule.children) {
314
+ if (child.id.startsWith(rootDir)) {
315
+ clearModuleCache(child.id, rootDir, visited);
316
+ }
317
+ }
318
+ delete require.cache[resolvedPath];
319
+ }
320
+ function resolveModule(modulePath, rootDir) {
321
+ clearModuleCache(modulePath, rootDir);
305
322
  return require(modulePath);
306
323
  }
307
324
  async function resolveHead(candidate, context) {
@@ -388,7 +405,7 @@ function createFileRouter(options) {
388
405
  message,
389
406
  payload
390
407
  };
391
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
408
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
392
409
  if (!import_node_fs.default.existsSync(errorPath)) {
393
410
  const fallback = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
394
411
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: statusCode }),
@@ -402,7 +419,7 @@ function createFileRouter(options) {
402
419
  }
403
420
  };
404
421
  }
405
- const errorModule = resolveModule(errorPath);
422
+ const errorModule = resolveModule(errorPath, pagesDir);
406
423
  const errorNode = await errorModule.default(errorProps);
407
424
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
408
425
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -451,7 +468,10 @@ function createFileRouter(options) {
451
468
  message: `Invalid middleware '${middlewareNames[0]}'`
452
469
  });
453
470
  }
454
- const middlewareModule = resolveModule(middlewaresPath);
471
+ const middlewareModule = resolveModule(
472
+ middlewaresPath,
473
+ pagesDir
474
+ );
455
475
  const registry = middlewareModule.middlewares;
456
476
  if (!registry) {
457
477
  if (!requiresNamedMiddleware) {
@@ -506,8 +526,8 @@ function createFileRouter(options) {
506
526
  params: match.params
507
527
  };
508
528
  activeContext = context;
509
- const pageModule = resolveModule(match.entry.filePath);
510
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
529
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
530
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
511
531
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
512
532
  activeContext = middlewareContext;
513
533
  const pageData = await resolvePageData(pageModule, middlewareContext);
package/dist/router.js CHANGED
@@ -270,8 +270,25 @@ function renderHeadToString(head) {
270
270
  }
271
271
  return tags.join("\n");
272
272
  }
273
- function resolveModule(modulePath) {
274
- delete __require.cache[modulePath];
273
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
274
+ const resolvedPath = __require.resolve(modulePath);
275
+ if (visited.has(resolvedPath)) {
276
+ return;
277
+ }
278
+ visited.add(resolvedPath);
279
+ const cachedModule = __require.cache[resolvedPath];
280
+ if (!cachedModule) {
281
+ return;
282
+ }
283
+ for (const child of cachedModule.children) {
284
+ if (child.id.startsWith(rootDir)) {
285
+ clearModuleCache(child.id, rootDir, visited);
286
+ }
287
+ }
288
+ delete __require.cache[resolvedPath];
289
+ }
290
+ function resolveModule(modulePath, rootDir) {
291
+ clearModuleCache(modulePath, rootDir);
275
292
  return __require(modulePath);
276
293
  }
277
294
  async function resolveHead(candidate, context) {
@@ -358,7 +375,7 @@ function createFileRouter(options) {
358
375
  message,
359
376
  payload
360
377
  };
361
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
378
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
362
379
  if (!fs.existsSync(errorPath)) {
363
380
  const fallback = /* @__PURE__ */ jsxs("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
364
381
  /* @__PURE__ */ jsx("h1", { children: statusCode }),
@@ -372,7 +389,7 @@ function createFileRouter(options) {
372
389
  }
373
390
  };
374
391
  }
375
- const errorModule = resolveModule(errorPath);
392
+ const errorModule = resolveModule(errorPath, pagesDir);
376
393
  const errorNode = await errorModule.default(errorProps);
377
394
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
378
395
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -421,7 +438,10 @@ function createFileRouter(options) {
421
438
  message: `Invalid middleware '${middlewareNames[0]}'`
422
439
  });
423
440
  }
424
- const middlewareModule = resolveModule(middlewaresPath);
441
+ const middlewareModule = resolveModule(
442
+ middlewaresPath,
443
+ pagesDir
444
+ );
425
445
  const registry = middlewareModule.middlewares;
426
446
  if (!registry) {
427
447
  if (!requiresNamedMiddleware) {
@@ -476,8 +496,8 @@ function createFileRouter(options) {
476
496
  params: match.params
477
497
  };
478
498
  activeContext = context;
479
- const pageModule = resolveModule(match.entry.filePath);
480
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
499
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
500
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
481
501
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
482
502
  activeContext = middlewareContext;
483
503
  const pageData = await resolvePageData(pageModule, middlewareContext);
@@ -412,8 +412,25 @@ function renderHeadToString(head) {
412
412
  }
413
413
  return tags.join("\n");
414
414
  }
415
- function resolveModule(modulePath) {
416
- delete require.cache[modulePath];
415
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
416
+ const resolvedPath = require.resolve(modulePath);
417
+ if (visited.has(resolvedPath)) {
418
+ return;
419
+ }
420
+ visited.add(resolvedPath);
421
+ const cachedModule = require.cache[resolvedPath];
422
+ if (!cachedModule) {
423
+ return;
424
+ }
425
+ for (const child of cachedModule.children) {
426
+ if (child.id.startsWith(rootDir)) {
427
+ clearModuleCache(child.id, rootDir, visited);
428
+ }
429
+ }
430
+ delete require.cache[resolvedPath];
431
+ }
432
+ function resolveModule(modulePath, rootDir) {
433
+ clearModuleCache(modulePath, rootDir);
417
434
  return require(modulePath);
418
435
  }
419
436
  async function resolveHead(candidate, context) {
@@ -500,7 +517,7 @@ function createFileRouter(options) {
500
517
  message,
501
518
  payload
502
519
  };
503
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
520
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
504
521
  if (!import_node_fs.default.existsSync(errorPath)) {
505
522
  const fallback = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
506
523
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: statusCode }),
@@ -514,7 +531,7 @@ function createFileRouter(options) {
514
531
  }
515
532
  };
516
533
  }
517
- const errorModule = resolveModule(errorPath);
534
+ const errorModule = resolveModule(errorPath, pagesDir);
518
535
  const errorNode = await errorModule.default(errorProps);
519
536
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
520
537
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -563,7 +580,10 @@ function createFileRouter(options) {
563
580
  message: `Invalid middleware '${middlewareNames[0]}'`
564
581
  });
565
582
  }
566
- const middlewareModule = resolveModule(middlewaresPath);
583
+ const middlewareModule = resolveModule(
584
+ middlewaresPath,
585
+ pagesDir
586
+ );
567
587
  const registry = middlewareModule.middlewares;
568
588
  if (!registry) {
569
589
  if (!requiresNamedMiddleware) {
@@ -618,8 +638,8 @@ function createFileRouter(options) {
618
638
  params: match.params
619
639
  };
620
640
  activeContext = context;
621
- const pageModule = resolveModule(match.entry.filePath);
622
- const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
641
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
642
+ const layoutModule = import_node_fs.default.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
623
643
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
624
644
  activeContext = middlewareContext;
625
645
  const pageData = await resolvePageData(pageModule, middlewareContext);
@@ -715,7 +735,21 @@ globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
715
735
  }
716
736
 
717
737
  if (id.startsWith("./")) {
718
- return require(path.resolve(process.cwd(), id.slice(2)));
738
+ const relativeId = id.slice(2);
739
+ const candidates = [
740
+ path.resolve(process.cwd(), relativeId),
741
+ path.resolve(process.cwd(), "..", relativeId)
742
+ ];
743
+ for (const candidate of candidates) {
744
+ try {
745
+ return require(candidate);
746
+ } catch (error) {
747
+ const missingCandidate = error && error.code === "MODULE_NOT_FOUND" && typeof error.message === "string" && error.message.includes("'" + candidate + "'");
748
+ if (!missingCandidate) {
749
+ throw error;
750
+ }
751
+ }
752
+ }
719
753
  }
720
754
 
721
755
  return require(id);
@@ -1019,22 +1053,64 @@ function normalizeClientManifest(manifest, options) {
1019
1053
  }
1020
1054
  function createServerConsumerManifest(manifest) {
1021
1055
  const consumerManifest = {};
1056
+ const normalizeWorkerModuleId = (requestKey, rawModuleId) => {
1057
+ if (typeof rawModuleId === "string" && rawModuleId.trim() !== "") {
1058
+ return rawModuleId;
1059
+ }
1060
+ if (typeof rawModuleId !== "number" || !Number.isFinite(rawModuleId)) {
1061
+ return null;
1062
+ }
1063
+ if (!requestKey || requestKey.trim() === "") {
1064
+ return String(rawModuleId);
1065
+ }
1066
+ if (requestKey.startsWith("file://")) {
1067
+ try {
1068
+ return (0, import_node_url.fileURLToPath)(requestKey);
1069
+ } catch {
1070
+ return String(rawModuleId);
1071
+ }
1072
+ }
1073
+ if (requestKey.startsWith("/")) {
1074
+ return requestKey;
1075
+ }
1076
+ if (requestKey.startsWith("./")) {
1077
+ return requestKey;
1078
+ }
1079
+ if (requestKey.startsWith("node_modules/") || requestKey.startsWith("build/")) {
1080
+ return `./${requestKey}`;
1081
+ }
1082
+ return requestKey;
1083
+ };
1084
+ const addReference = (lookupKey, reference) => {
1085
+ if (!lookupKey || lookupKey.trim() === "") {
1086
+ return;
1087
+ }
1088
+ if (lookupKey in consumerManifest) {
1089
+ return;
1090
+ }
1091
+ consumerManifest[lookupKey] = {
1092
+ "*": reference
1093
+ };
1094
+ };
1022
1095
  for (const [key, value] of Object.entries(manifest)) {
1023
1096
  if (!value || typeof value !== "object") {
1024
1097
  continue;
1025
1098
  }
1026
1099
  const entry = value;
1027
- if (typeof entry.id !== "string" || entry.id.trim() === "") {
1100
+ const workerModuleId = normalizeWorkerModuleId(key, entry.id);
1101
+ if (!workerModuleId) {
1028
1102
  continue;
1029
1103
  }
1030
- consumerManifest[key] = {
1031
- "*": {
1032
- id: entry.id,
1033
- chunks: [],
1034
- name: entry.name ?? "*",
1035
- ...entry.async ? { async: entry.async } : {}
1036
- }
1104
+ const reference = {
1105
+ id: workerModuleId,
1106
+ chunks: Array.isArray(entry.chunks) ? entry.chunks : [],
1107
+ name: entry.name ?? "*",
1108
+ ...entry.async ? { async: entry.async } : {}
1037
1109
  };
1110
+ addReference(key, reference);
1111
+ if (typeof entry.id === "number" && Number.isFinite(entry.id)) {
1112
+ addReference(String(entry.id), reference);
1113
+ }
1038
1114
  }
1039
1115
  return consumerManifest;
1040
1116
  }
@@ -384,8 +384,25 @@ function renderHeadToString(head) {
384
384
  }
385
385
  return tags.join("\n");
386
386
  }
387
- function resolveModule(modulePath) {
388
- delete __require.cache[modulePath];
387
+ function clearModuleCache(modulePath, rootDir, visited = /* @__PURE__ */ new Set()) {
388
+ const resolvedPath = __require.resolve(modulePath);
389
+ if (visited.has(resolvedPath)) {
390
+ return;
391
+ }
392
+ visited.add(resolvedPath);
393
+ const cachedModule = __require.cache[resolvedPath];
394
+ if (!cachedModule) {
395
+ return;
396
+ }
397
+ for (const child of cachedModule.children) {
398
+ if (child.id.startsWith(rootDir)) {
399
+ clearModuleCache(child.id, rootDir, visited);
400
+ }
401
+ }
402
+ delete __require.cache[resolvedPath];
403
+ }
404
+ function resolveModule(modulePath, rootDir) {
405
+ clearModuleCache(modulePath, rootDir);
389
406
  return __require(modulePath);
390
407
  }
391
408
  async function resolveHead(candidate, context) {
@@ -472,7 +489,7 @@ function createFileRouter(options) {
472
489
  message,
473
490
  payload
474
491
  };
475
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
492
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
476
493
  if (!fs.existsSync(errorPath)) {
477
494
  const fallback = /* @__PURE__ */ jsxs("main", { style: { fontFamily: "system-ui, sans-serif", padding: 24 }, children: [
478
495
  /* @__PURE__ */ jsx("h1", { children: statusCode }),
@@ -486,7 +503,7 @@ function createFileRouter(options) {
486
503
  }
487
504
  };
488
505
  }
489
- const errorModule = resolveModule(errorPath);
506
+ const errorModule = resolveModule(errorPath, pagesDir);
490
507
  const errorNode = await errorModule.default(errorProps);
491
508
  const layoutHead = layoutModule ? await resolveHead(layoutModule, context) : void 0;
492
509
  const errorHead = await resolveHead(errorModule, errorProps);
@@ -535,7 +552,10 @@ function createFileRouter(options) {
535
552
  message: `Invalid middleware '${middlewareNames[0]}'`
536
553
  });
537
554
  }
538
- const middlewareModule = resolveModule(middlewaresPath);
555
+ const middlewareModule = resolveModule(
556
+ middlewaresPath,
557
+ pagesDir
558
+ );
539
559
  const registry = middlewareModule.middlewares;
540
560
  if (!registry) {
541
561
  if (!requiresNamedMiddleware) {
@@ -590,8 +610,8 @@ function createFileRouter(options) {
590
610
  params: match.params
591
611
  };
592
612
  activeContext = context;
593
- const pageModule = resolveModule(match.entry.filePath);
594
- const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath) : null;
613
+ const pageModule = resolveModule(match.entry.filePath, pagesDir);
614
+ const layoutModule = fs.existsSync(layoutPath) ? resolveModule(layoutPath, pagesDir) : null;
595
615
  const middlewareContext = await resolveMiddlewares(pageModule.middlewares, context);
596
616
  activeContext = middlewareContext;
597
617
  const pageData = await resolvePageData(pageModule, middlewareContext);
@@ -687,7 +707,21 @@ globalThis.__webpack_require__ = function __webframezNodeRequire(id) {
687
707
  }
688
708
 
689
709
  if (id.startsWith("./")) {
690
- return require(path.resolve(process.cwd(), id.slice(2)));
710
+ const relativeId = id.slice(2);
711
+ const candidates = [
712
+ path.resolve(process.cwd(), relativeId),
713
+ path.resolve(process.cwd(), "..", relativeId)
714
+ ];
715
+ for (const candidate of candidates) {
716
+ try {
717
+ return require(candidate);
718
+ } catch (error) {
719
+ const missingCandidate = error && error.code === "MODULE_NOT_FOUND" && typeof error.message === "string" && error.message.includes("'" + candidate + "'");
720
+ if (!missingCandidate) {
721
+ throw error;
722
+ }
723
+ }
724
+ }
691
725
  }
692
726
 
693
727
  return require(id);
@@ -991,22 +1025,64 @@ function normalizeClientManifest(manifest, options) {
991
1025
  }
992
1026
  function createServerConsumerManifest(manifest) {
993
1027
  const consumerManifest = {};
1028
+ const normalizeWorkerModuleId = (requestKey, rawModuleId) => {
1029
+ if (typeof rawModuleId === "string" && rawModuleId.trim() !== "") {
1030
+ return rawModuleId;
1031
+ }
1032
+ if (typeof rawModuleId !== "number" || !Number.isFinite(rawModuleId)) {
1033
+ return null;
1034
+ }
1035
+ if (!requestKey || requestKey.trim() === "") {
1036
+ return String(rawModuleId);
1037
+ }
1038
+ if (requestKey.startsWith("file://")) {
1039
+ try {
1040
+ return fileURLToPath(requestKey);
1041
+ } catch {
1042
+ return String(rawModuleId);
1043
+ }
1044
+ }
1045
+ if (requestKey.startsWith("/")) {
1046
+ return requestKey;
1047
+ }
1048
+ if (requestKey.startsWith("./")) {
1049
+ return requestKey;
1050
+ }
1051
+ if (requestKey.startsWith("node_modules/") || requestKey.startsWith("build/")) {
1052
+ return `./${requestKey}`;
1053
+ }
1054
+ return requestKey;
1055
+ };
1056
+ const addReference = (lookupKey, reference) => {
1057
+ if (!lookupKey || lookupKey.trim() === "") {
1058
+ return;
1059
+ }
1060
+ if (lookupKey in consumerManifest) {
1061
+ return;
1062
+ }
1063
+ consumerManifest[lookupKey] = {
1064
+ "*": reference
1065
+ };
1066
+ };
994
1067
  for (const [key, value] of Object.entries(manifest)) {
995
1068
  if (!value || typeof value !== "object") {
996
1069
  continue;
997
1070
  }
998
1071
  const entry = value;
999
- if (typeof entry.id !== "string" || entry.id.trim() === "") {
1072
+ const workerModuleId = normalizeWorkerModuleId(key, entry.id);
1073
+ if (!workerModuleId) {
1000
1074
  continue;
1001
1075
  }
1002
- consumerManifest[key] = {
1003
- "*": {
1004
- id: entry.id,
1005
- chunks: [],
1006
- name: entry.name ?? "*",
1007
- ...entry.async ? { async: entry.async } : {}
1008
- }
1076
+ const reference = {
1077
+ id: workerModuleId,
1078
+ chunks: Array.isArray(entry.chunks) ? entry.chunks : [],
1079
+ name: entry.name ?? "*",
1080
+ ...entry.async ? { async: entry.async } : {}
1009
1081
  };
1082
+ addReference(key, reference);
1083
+ if (typeof entry.id === "number" && Number.isFinite(entry.id)) {
1084
+ addReference(String(entry.id), reference);
1085
+ }
1010
1086
  }
1011
1087
  return consumerManifest;
1012
1088
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-react",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "TypeScript React RSC addition for @webtypen/webframez-core",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "author": {