@pylonsync/functions 0.3.241 → 0.3.243

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": "@pylonsync/functions",
3
- "version": "0.3.241",
3
+ "version": "0.3.243",
4
4
  "description": "TypeScript function runtime for pylon — defines server-side queries, mutations, and actions.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -709,6 +709,16 @@ async function _doBuildInner(fs: any, path: any, cwd: string): Promise<BuildOutp
709
709
  const result = await Bun.build({
710
710
  entrypoints: entryPaths,
711
711
  outdir,
712
+ // Pin the build root to the project dir, NOT the inferred common
713
+ // parent of the entrypoints (which is `.pylon/`). Bun discovers
714
+ // `tsconfig.json` from `root`, and the entries we stage under
715
+ // `.pylon/client-entry-*.tsx` would otherwise resolve tsconfig from
716
+ // `.pylon/` and never see the project's `compilerOptions.paths` — so
717
+ // `@/` path-alias imports (e.g. shadcn's `@/lib/utils`) compile fine
718
+ // server-side but fail in the client bundle. `[name]-[hash]` naming
719
+ // has no `[dir]`, so pinning root doesn't move outputs. Keeps client
720
+ // and server alias resolution identical.
721
+ root: cwd,
712
722
  target: "browser",
713
723
  format: "esm",
714
724
  minify: true,
@@ -737,6 +737,22 @@ async function streamWithHeadInjection(
737
737
  if (carry) sendChunk(carry);
738
738
  }
739
739
 
740
+ /**
741
+ * Dev-only browser live-reload client, injected at the end of every SSR
742
+ * page when PYLON_DEV_MODE is set. Subscribes to the runtime's
743
+ * `/_pylon/dev/live` Server-Sent-Events endpoint (see frontend.rs
744
+ * `serve_dev_live_reload`), which streams this process's boot id in a
745
+ * `hello` event. EventSource auto-reconnects when `pylon dev` restarts; the
746
+ * fresh process advertises a new boot id, so a changed id ⇒ the tab reloads.
747
+ * No-ops in browsers without EventSource (none in practice).
748
+ */
749
+ const DEV_LIVE_RELOAD_SNIPPET =
750
+ "<script>(function(){if(typeof EventSource===\"undefined\")return;" +
751
+ "var b=null;try{var s=new EventSource(\"/_pylon/dev/live\");" +
752
+ "s.addEventListener(\"hello\",function(e){" +
753
+ "if(b!==null&&e.data!==b){s.close();location.reload();return;}b=e.data;});" +
754
+ "}catch(_){}})();</script>";
755
+
740
756
  /**
741
757
  * Build the <head> blob for a boundary render: the union of every route's
742
758
  * stylesheet links from the client build manifest. Boundary modules aren't
@@ -1194,6 +1210,15 @@ export async function handleRenderRoute(
1194
1210
  } else {
1195
1211
  tail += `<script>console.warn(${JSON.stringify(`[pylon ssr] hydration disabled: ${preloadManifestErr}`)})</script>`;
1196
1212
  }
1213
+ // Dev-only browser live-reload. `pylon dev` (PYLON_DEV_MODE=1) re-execs
1214
+ // the whole process on every file edit; each process serves a fresh
1215
+ // boot id from /_pylon/dev/live. This client subscribes via
1216
+ // EventSource and reloads the tab when the boot id changes — so saving
1217
+ // a page, a component, or app/globals.css refreshes the browser with
1218
+ // no manual F5. Stripped entirely in production builds.
1219
+ if (process.env.PYLON_DEV_MODE) {
1220
+ tail += DEV_LIVE_RELOAD_SNIPPET;
1221
+ }
1197
1222
  send({
1198
1223
  type: "render_chunk",
1199
1224
  call_id: msg.call_id,