From 5d0a2530ae8c3c470568c07eefa922c2e10aa251 Mon Sep 17 00:00:00 2001 From: Sawyer Cutler Date: Thu, 24 Sep 2026 22:54:12 -0700 Subject: [PATCH] build: drop the git-install prepare hook The package installs from npm; prepack builds dist for the tarball. --- CHANGELOG.md | 3 ++ IMPLEMENTATION.md | 6 +-- package.json | 3 +- scripts/prepare.mjs | 98 --------------------------------------------- 4 files changed, 5 insertions(+), 105 deletions(-) delete mode 100644 scripts/prepare.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index bd18ce71..825baefc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ contract — modules that are not exported are internal and may change in any re ### Breaking changes since 0.1.0 +- **Git installs are no longer supported.** The `prepare` hook that built `dist/` on a + `github:corbitsdev/react-ui#` install is gone, so such an install ships no build + output. Install from npm: `npm add @corbits/react-ui`. - **84 modules removed — every module no known consumer imports.** A usage audit across the workbench, portal, scout and solutions-builder codebases showed these surfaces were unreachable from any consumer, so they were deleted rather than carried as semver diff --git a/IMPLEMENTATION.md b/IMPLEMENTATION.md index 9743ee43..e1de2127 100644 --- a/IMPLEMENTATION.md +++ b/IMPLEMENTATION.md @@ -35,8 +35,6 @@ by `&&`: Source imports are relative and carry `.js` extensions. There is no path alias. `prepack` runs the whole build so a failing gate cannot be packed. -`prepare` (`scripts/prepare.mjs`) builds `dist/` on a git install; it is a -no-op when `dist/` is already present. Other scripts: `bun run typecheck`, `bun run lint` (eslint), `bun run dep-guard` (`scripts/dep-guard.mjs` — fails if any file imports @@ -73,6 +71,4 @@ the rest of the library does not. ## Publish Registry install is the documented path (`npm` / `pnpm` / `yarn` / -`bun add @corbits/react-ui`). `publishConfig.access` is `public`. A git -install still works via `prepare`, and under bun that requires -`trustedDependencies: ["@corbits/react-ui"]`. +`bun add @corbits/react-ui`). `publishConfig.access` is `public`. diff --git a/package.json b/package.json index 0570ea64..fec13416 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,7 @@ "contrast-test": "node scripts/contrast-test.mjs", "stories": "ladle serve --host 127.0.0.1", "stories:build": "ladle build", - "prepack": "bun run build", - "prepare": "node scripts/prepare.mjs" + "prepack": "bun run build" }, "dependencies": { "class-variance-authority": "^0.7.1", diff --git a/scripts/prepare.mjs b/scripts/prepare.mjs deleted file mode 100644 index 0104d338..00000000 --- a/scripts/prepare.mjs +++ /dev/null @@ -1,98 +0,0 @@ -/** - * `prepare` hook — builds `dist/` when the package is installed from git. - * - * The package publishes `dist/` only (`files`), and every entry in the - * `exports` map points there. A registry tarball therefore arrives already - * built, via `prepack`. A git install does not: it gets the repository, so - * something has to build on the way in, and `prepare` is the one lifecycle - * hook package managers run at that moment. Without it every - * `@corbits/react-ui/...` import in the consumer resolves to a file that was - * never generated, and the failure lands in the consumer's tree, where they - * cannot fix it. - * - * Three things make this more than a one-line script: - * - * 1. `prepare` also runs for the *root* project on a plain `bun install` here - * in the repository. Building then would be wasted work at best, and - * recursive at worst (see 2). Being installed as a dependency is what - * distinguishes the two cases, and the honest signal for it is that the - * package directory sits inside a `node_modules` tree. - * 2. bun does not install a git dependency's devDependencies, and the whole - * toolchain (swc, tsc, tailwind) is a devDependency — as it should be, a - * consumer must not inherit them as runtime deps. So the git-install path - * installs them itself, immediately before the build that needs them. - * 3. That build cannot run inside the consumer's `node_modules`. Declaration - * emit has to name React's types, and installing the toolchain in place - * puts them under a path like - * `/node_modules/.bun/@corbits+react-ui@.../node_modules/@types/react`. - * TypeScript refuses to write that into a `.d.ts` (TS2742, "cannot be named - * without a reference to ... This is likely not portable"), so `build:types` - * fails and every later step is skipped — including `build:css`, which is - * why a consumer would otherwise be left with JavaScript but no - * stylesheets. Building in a scratch directory outside any `node_modules` - * tree keeps those paths nameable; it is the same layout the build already - * runs in during development and on CI. - * - * Deliberately a no-op when `dist/` is already present: repeat installs of the - * same commit should not pay for a rebuild. - */ -import { execFileSync } from "node:child_process"; -import { cpSync, existsSync, mkdtempSync, rmSync } from "node:fs"; -import { tmpdir } from "node:os"; -import { dirname, join, sep } from "node:path"; -import { fileURLToPath } from "node:url"; - -const packageDir = dirname(dirname(fileURLToPath(import.meta.url))); - -if (existsSync(join(packageDir, "dist", "index.js"))) { - process.exit(0); -} - -const installedAsDependency = packageDir.split(sep).includes("node_modules"); -if (!installedAsDependency) { - // Developing the repository itself. `bun run build` is a documented step of - // getting set up (CONTRIBUTING.md) and stays an explicit one — a `prepare` - // that silently ran the whole gate on every `bun install` would be a - // surprise, and the recursive `bun install` below would be a worse one. - process.exit(0); -} - -// The toolchain install below is itself a `bun install`. It no longer runs in -// this directory, but the scratch copy carries this same script, and bun runs -// `prepare` for the root project too — so without a marker the copy would -// start the whole dance again. This breaks that cycle. -const RECURSION_GUARD = "CORBITS_REACT_UI_PREPARE"; -if (process.env[RECURSION_GUARD] === "1") { - process.exit(0); -} - -function run(command, args, cwd) { - execFileSync(command, args, { - cwd, - stdio: "inherit", - env: { ...process.env, [RECURSION_GUARD]: "1" }, - }); -} - -console.log("@corbits/react-ui: git install — building dist/"); - -const buildDir = mkdtempSync(join(tmpdir(), "corbits-react-ui-")); -try { - cpSync(packageDir, buildDir, { - recursive: true, - // `node_modules` is what carries the unnameable layout, so copying it - // would defeat the point; `dist` is the thing being built. - filter: (source) => { - if (source === packageDir) return true; - const [top] = source.slice(packageDir.length + 1).split(sep); - return top !== "node_modules" && top !== "dist"; - }, - }); - - run("bun", ["install"], buildDir); - run("bun", ["run", "build"], buildDir); - - cpSync(join(buildDir, "dist"), join(packageDir, "dist"), { recursive: true }); -} finally { - rmSync(buildDir, { recursive: true, force: true }); -}