Unverified Commit 2743ffc3 authored by Thierry Delafontaine's avatar Thierry Delafontaine
Browse files

models-dev: add patch to rename hashed index file back to index.html

This change addresses an issue in Bun 1.2.13 (used in release 25.05)
where HTML entry points are generated with a hash appended to the
filename. As a result, the build fails unless the hashed index file is
renamed back to `index.html`.

The added patch scans the `./dist` directory for the hashed index
file and renames it back to `index.html` to ensure compatibility with
subsequent build steps.

(cherry picked from commit faadfb7a)
parent 0a674d09
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -41,6 +41,13 @@ stdenvNoCC.mkDerivation (finalAttrs: {

    dontConfigure = true;

    patches = [
      # In bun 1.2.13 (release-25.05) HTML entrypoints get content hashes
      # appended → index.html becomes index-pq8vj7za.html in ./dist. So, we
      # rename the index file back to index.html
      ./post-build-rename-index-file.patch
    ];

    buildPhase = ''
      runHook preBuild

+18 −0
Original line number Diff line number Diff line
diff --git i/packages/web/script/build.ts w/packages/web/script/build.ts
index 9bdcdb3..e9ce1c9 100755
--- i/packages/web/script/build.ts
+++ w/packages/web/script/build.ts
@@ -14,6 +14,13 @@ for await (const file of new Bun.Glob("./public/*").scan()) {
   await Bun.write(file.replace("./public/", "./dist/"), Bun.file(file));
 }
 
+const distFiles = await fs.readdir("./dist");
+const htmlFile = distFiles.find(file => file.startsWith("index-") && file.endsWith(".html"));
+
+if (htmlFile) {
+  await fs.rename(`./dist/${htmlFile}`, "./dist/index.html");
+}
+
 let html = await Bun.file("./dist/index.html").text();
 html = html.replace("<!--static-->", Rendered);
 await Bun.write("./dist/index.html", html);