diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa9f9668..cc8c82846 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,14 @@ loaded before stops loading. This vocabulary ships in 1.3.0 with `metamodelVersi and the `metaobjects-authoring` skill now send grouped totals, dashboard numbers and read-only report views to `object.report` (`references/declaring-reports.md`) before the `@sql` escape, which they describe as the last resort for bodies the vocabulary cannot express. +- **`@metaobjectsdev/cli` no longer installs the native Biome binary.** `codegen-ts-react`, + `codegen-ts-tanstack` and the source-only `codegen-ts-angular` declared `@biomejs/biome` as a + peer dependency, which npm installs automatically, so every CLI install carried the ~94 MB + `@biomejs/cli-` binary that nothing runs: codegen formats through the WebAssembly + build (`@biomejs/wasm-nodejs`). The peer is gone (it stays a devDependency for this repo's own + lint gate), and a fresh npm install of the CLI drops from 245 MB to 151 MB of `node_modules`. + `scripts/check-peer-ranges.ts` now fails a publishable package that requires `@biomejs/biome` + through `dependencies` or a non-optional peer. ### Fixed diff --git a/bun.lock b/bun.lock index f0968a371..5f8e86e3c 100644 --- a/bun.lock +++ b/bun.lock @@ -221,9 +221,6 @@ "bun-types": "latest", "typescript": "^5.6.0", }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0", - }, }, "server/typescript/packages/codegen-ts-react": { "name": "@metaobjectsdev/codegen-ts-react", @@ -239,9 +236,6 @@ "bun-types": "latest", "typescript": "^5.6.0", }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0", - }, }, "server/typescript/packages/codegen-ts-tanstack": { "name": "@metaobjectsdev/codegen-ts-tanstack", @@ -257,9 +251,6 @@ "bun-types": "latest", "typescript": "^5.6.0", }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0", - }, }, "server/typescript/packages/conformance": { "name": "@metaobjectsdev/conformance", diff --git a/scripts/check-peer-ranges.ts b/scripts/check-peer-ranges.ts index 2884ff365..5033d3f29 100755 --- a/scripts/check-peer-ranges.ts +++ b/scripts/check-peer-ranges.ts @@ -25,6 +25,15 @@ * version we chose — never the version an adopter would get. This check works because * it reads MANIFESTS, not `node_modules`, so it needs no network and cannot be fooled * by a warm lockfile. + * + * Second rule, same walk: no publishable package may REQUIRE the native Biome + * formatter (`@biomejs/biome`, which pulls a ~94 MB per-platform `@biomejs/cli-*` + * binary) through `dependencies` or a non-optional peer. npm installs required peers + * automatically, so a single generator package declaring it put the binary into every + * `@metaobjectsdev/cli` install, though nothing at run time uses it: codegen formats + * through the WebAssembly build (`@biomejs/wasm-nodejs` + `@biomejs/js-api`, see + * `codegen-ts/src/format.ts`). Development use belongs in `devDependencies`; a genuine + * run-time need must be an optional peer (`peerDependenciesMeta`). */ import { readdirSync, readFileSync, existsSync } from "node:fs"; import { join } from "node:path"; @@ -35,8 +44,13 @@ const ROOTS = ["server/typescript/packages", "client/web/packages"]; /** A version no real release will reach. If the range still matches, it has no ceiling. */ const BEYOND_ANY_REAL_VERSION = "9999.0.0"; +/** The native formatter and its per-platform binaries. */ +const isNativeFormatter = (name: string): boolean => + name === "@biomejs/biome" || name.startsWith("@biomejs/cli-"); + interface Violation { pkg: string; peer: string; range: string } const violations: Violation[] = []; +const nativeFormatter: { pkg: string; dep: string; field: string }[] = []; let checked = 0; for (const root of ROOTS) { @@ -44,9 +58,20 @@ for (const root of ROOTS) { const manifest = join(REPO, root, dir, "package.json"); if (!existsSync(manifest)) continue; const pkg = JSON.parse(readFileSync(manifest, "utf8")) as { - name: string; private?: boolean; peerDependencies?: Record; + name: string; private?: boolean; + dependencies?: Record; + peerDependencies?: Record; + peerDependenciesMeta?: Record; }; if (pkg.private === true) continue; // never published — its peers bind nobody + for (const dep of Object.keys(pkg.dependencies ?? {})) { + if (isNativeFormatter(dep)) nativeFormatter.push({ pkg: pkg.name, dep, field: "dependencies" }); + } + for (const dep of Object.keys(pkg.peerDependencies ?? {})) { + if (isNativeFormatter(dep) && pkg.peerDependenciesMeta?.[dep]?.optional !== true) { + nativeFormatter.push({ pkg: pkg.name, dep, field: "peerDependencies (required)" }); + } + } for (const [peer, range] of Object.entries(pkg.peerDependencies ?? {})) { checked++; if (Bun.semver.satisfies(BEYOND_ANY_REAL_VERSION, range)) { @@ -71,4 +96,15 @@ if (violations.length > 0) { process.exit(1); } +if (nativeFormatter.length > 0) { + console.error("✖ native Biome formatter required at install time:\n"); + for (const v of nativeFormatter) console.error(` ${v.pkg}\n ${v.field}: "${v.dep}"`); + console.error( + `\nnpm installs it (a ~94 MB native binary) into every adopter's tree, and codegen` + + `\nformats through @biomejs/wasm-nodejs instead. Move it to devDependencies, or, if` + + `\nshipped code really needs it, mark the peer optional in peerDependenciesMeta.\n`, + ); + process.exit(1); +} + console.log(`peer-range bounds: OK (${checked} peer ranges, all bounded)`); diff --git a/scripts/check-reference-templates-lint.ts b/scripts/check-reference-templates-lint.ts index aaec9441a..9602ca7da 100644 --- a/scripts/check-reference-templates-lint.ts +++ b/scripts/check-reference-templates-lint.ts @@ -76,8 +76,9 @@ export async function discoverTemplates(repo: string = REPO): Promise return found.sort(); } -/** biome is a dependency of the codegen packages (it runs the `formatTs` pass), so a - * binary is present after `bun install`. Any of them is the same pinned version. */ +/** biome is a devDependency of the codegen packages (shipped code formats through the + * WASM build instead), so a binary is present after `bun install`. Any of them is the + * same pinned version. */ export function resolveBiomeBin(repo: string = REPO): string | undefined { for (const root of PACKAGE_ROOTS) { const rootDir = join(repo, root); diff --git a/server/typescript/packages/cli/README.md b/server/typescript/packages/cli/README.md index 09477f99a..e5f43d092 100644 --- a/server/typescript/packages/cli/README.md +++ b/server/typescript/packages/cli/README.md @@ -28,7 +28,7 @@ bun run build:binary # → dist/meta (compiled for the build host's OS/ar ./dist/meta --help ``` -The build externalizes two optional Biome WASM backends (`@biomejs/wasm-bundler`, `@biomejs/wasm-web`) that the CLI never loads — only the native Biome backend is used. +The build externalizes two optional Biome WASM backends (`@biomejs/wasm-bundler`, `@biomejs/wasm-web`) that the CLI never loads — codegen formats through the Node WebAssembly backend (`@biomejs/wasm-nodejs`), and the native Biome binary is not installed with the CLI. ### Cross-compiling for other platforms diff --git a/server/typescript/packages/codegen-ts-angular/package.json b/server/typescript/packages/codegen-ts-angular/package.json index 58c65363f..1d456ab31 100644 --- a/server/typescript/packages/codegen-ts-angular/package.json +++ b/server/typescript/packages/codegen-ts-angular/package.json @@ -50,9 +50,6 @@ "@metaobjectsdev/codegen-ts": "workspace:*", "ts-poet": "^6.10.0" }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0" - }, "devDependencies": { "@biomejs/biome": "^1.9.0", "bun-types": "latest", diff --git a/server/typescript/packages/codegen-ts-react/package.json b/server/typescript/packages/codegen-ts-react/package.json index 26045c891..57ab1b9b4 100644 --- a/server/typescript/packages/codegen-ts-react/package.json +++ b/server/typescript/packages/codegen-ts-react/package.json @@ -49,9 +49,6 @@ "@metaobjectsdev/codegen-ts": "workspace:*", "ts-poet": "^6.10.0" }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0" - }, "devDependencies": { "@biomejs/biome": "^1.9.0", "@metaobjectsdev/test-generators": "workspace:*", diff --git a/server/typescript/packages/codegen-ts-tanstack/package.json b/server/typescript/packages/codegen-ts-tanstack/package.json index d5f890d14..6b6a79593 100644 --- a/server/typescript/packages/codegen-ts-tanstack/package.json +++ b/server/typescript/packages/codegen-ts-tanstack/package.json @@ -48,9 +48,6 @@ "@metaobjectsdev/codegen-ts": "workspace:*", "ts-poet": "^6.10.0" }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0" - }, "devDependencies": { "@biomejs/biome": "^1.9.0", "@metaobjectsdev/test-generators": "workspace:*",