diff --git a/apps/fabro-web/scripts/build.ts b/apps/fabro-web/scripts/build.ts index 601c5db34..2e7c967fb 100644 --- a/apps/fabro-web/scripts/build.ts +++ b/apps/fabro-web/scripts/build.ts @@ -10,7 +10,7 @@ import { symlink, writeFile, } from "node:fs/promises"; -import { join, relative } from "node:path"; +import { dirname, join, relative } from "node:path"; declare const Bun: any; @@ -20,9 +20,20 @@ const buildsRootDir = join(rootPath, ".dist-builds"); const distPath = join(rootPath, "dist"); const publicDir = join(rootPath, "public"); const templatePath = join(rootPath, "index.template.html"); -const pierreWorkerDir = join(rootPath, "node_modules", "@pierre", "diffs", "dist", "worker"); const watch = Bun.argv.includes("--watch"); +// Locate dependencies through module resolution rather than hardcoded +// node_modules paths: where packages land on disk depends on the Bun install +// linker (hoisted puts them at the workspace root, isolated symlinks them into +// the app's node_modules), so any fixed path breaks on one of the layouts. +const pierreWorkerDir = join(dirname(Bun.resolveSync("@pierre/diffs", rootPath)), "worker"); + +const tailwindCliPackageJsonPath = Bun.resolveSync("@tailwindcss/cli/package.json", rootPath); +const tailwindCliBin = join( + dirname(tailwindCliPackageJsonPath), + JSON.parse(await readFile(tailwindCliPackageJsonPath, "utf8")).bin.tailwindcss, +); + function newBuildId(): string { return `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`; } @@ -47,7 +58,8 @@ async function buildOnce() { } const cssResult = await Bun.spawn([ - "./node_modules/.bin/tailwindcss", + process.execPath, + tailwindCliBin, "-i", "app/app.css", "-o", diff --git a/bunfig.toml b/bunfig.toml new file mode 100644 index 000000000..f783a0e5a --- /dev/null +++ b/bunfig.toml @@ -0,0 +1,9 @@ +# Pin the install linker so every contributor's bun install produces the same +# node_modules layout. Bun < 1.3 defaulted workspaces to the hoisted linker +# (packages at the workspace root); Bun >= 1.3 defaults to isolated (packages +# symlinked into each app's node_modules from a central store). Tooling that +# touches node_modules should not have to handle both. +# +# Requires Bun >= 1.3. +[install] +linker = "isolated"