@pylonsync/functions 0.3.279 → 0.3.280

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.279",
3
+ "version": "0.3.280",
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",
@@ -756,9 +756,30 @@ async function _prebuiltBundle(): Promise<BuildOutput | null> {
756
756
  const path = pathMod.default ?? pathMod;
757
757
  const outdir = path.join(process.cwd(), ".pylon", "client-build");
758
758
  const manifestPath = path.join(outdir, "manifest.json");
759
+ if (!fs.existsSync(manifestPath)) return null;
760
+
761
+ // Reuse a prebuilt bundle when it's explicitly marked (`.prebuilt`) OR when
762
+ // its manifest already targets an ABSOLUTE (CDN) `public_prefix`. The builder
763
+ // bakes an absolute prefix only when it pre-built for the CDN, and it
764
+ // published the hashed assets under THOSE exact hashes — so the runtime must
765
+ // serve this exact manifest verbatim (a local rebuild emits different hashes
766
+ // that would 404 on the CDN). The manifest is a regular file that always
767
+ // ships with the build; keying on it (not just the `.prebuilt` dotfile, which
768
+ // can be dropped in transit) makes reuse robust. A same-origin
769
+ // `/_pylon/build/` manifest is a normal dev/local build → don't short-circuit
770
+ // (let dev hot-rebuild).
759
771
  const marker = path.join(outdir, ".prebuilt");
760
- if (fs.existsSync(marker) && fs.existsSync(manifestPath)) {
761
- return { manifestPath, outdir };
772
+ if (fs.existsSync(marker)) return { manifestPath, outdir };
773
+ try {
774
+ const m = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
775
+ if (
776
+ typeof m.public_prefix === "string" &&
777
+ /^https?:\/\//i.test(m.public_prefix)
778
+ ) {
779
+ return { manifestPath, outdir };
780
+ }
781
+ } catch {
782
+ /* unreadable/partial manifest → fall through and rebuild */
762
783
  }
763
784
  return null;
764
785
  }