weifuwu 0.17.11 → 0.17.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -919,6 +919,12 @@ var TsxInstance = class {
919
919
  };
920
920
  this.router.all("/*", handler);
921
921
  }
922
+ for (const p of pages) {
923
+ if (p.entryPath) {
924
+ const rootLayouts = resolveLayouts(this.pagesDir, this.pagesDir);
925
+ this.registerClientBundleRoute(p.entryPath, p.layouts.length > 0 ? p.layouts : rootLayouts, this.pagesDir);
926
+ }
927
+ }
922
928
  await this.setupTailwind();
923
929
  if (isDev) {
924
930
  this.router.ws("/__weifuwu/livereload", {
@@ -1022,15 +1028,21 @@ ${src}`;
1022
1028
  }
1023
1029
  }
1024
1030
  async getOrBuildClientBundle(entryPath, layoutPaths, pagesDir) {
1031
+ const key = id(entryPath);
1032
+ const url = `/__wfw/client/${key}.js`;
1033
+ this.clientBuildParams.set(key, { entryPath, layoutPaths, pagesDir });
1034
+ if (!this.clientBundleCache.has(key)) {
1035
+ const buf = await this.buildClientBundle(entryPath, layoutPaths, pagesDir);
1036
+ if (!buf) return null;
1037
+ this.clientBundleCache.set(key, buf);
1038
+ }
1039
+ return { url };
1040
+ }
1041
+ registerClientBundleRoute(entryPath, layoutPaths, pagesDir) {
1025
1042
  const key = id(entryPath);
1026
1043
  const url = `/__wfw/client/${key}.js`;
1027
1044
  this.clientBuildParams.set(key, { entryPath, layoutPaths, pagesDir });
1028
1045
  if (!this.clientRouteLog.has(url)) {
1029
- if (!this.clientBundleCache.has(key)) {
1030
- const buf = await this.buildClientBundle(entryPath, layoutPaths, pagesDir);
1031
- if (!buf) return null;
1032
- this.clientBundleCache.set(key, buf);
1033
- }
1034
1046
  this.router.get(url, async () => {
1035
1047
  let buf = this.clientBundleCache.get(key);
1036
1048
  if (!buf) {
@@ -1049,7 +1061,6 @@ ${src}`;
1049
1061
  });
1050
1062
  this.clientRouteLog.add(url);
1051
1063
  }
1052
- return { url };
1053
1064
  }
1054
1065
  // ── SSR handler ───────────────────────────────────────────────────────────
1055
1066
  makeSsrHandler(entryPath, layoutPaths, loadPath) {
@@ -25,6 +25,7 @@ export declare class TsxInstance {
25
25
  private setupTailwind;
26
26
  private buildClientBundle;
27
27
  private getOrBuildClientBundle;
28
+ private registerClientBundleRoute;
28
29
  private makeSsrHandler;
29
30
  private startFileWatcher;
30
31
  private recompileAndSwap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weifuwu",
3
- "version": "0.17.11",
3
+ "version": "0.17.12",
4
4
  "description": "Web-standard HTTP framework for Node.js — (req, ctx) => Response",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",