Skip to content

Commit 30b2897

Browse files
authored
fix(cli): stop installing the native Biome binary with every CLI install (#564)
* fix(codegen-ts-*): drop the @biomejs/biome peer so the CLI stops installing the native binary codegen-ts-react, codegen-ts-tanstack and codegen-ts-angular declared @biomejs/biome as a peer, which npm auto-installs, putting the ~94 MB native @biomejs/cli-<platform> binary into every CLI install. Nothing shipped uses it: formatting goes through @biomejs/wasm-nodejs. The devDependency stays for the repo's lint gate. check-peer-ranges.ts now rejects a publishable package that requires the native formatter. Fresh CLI install: 245 MB -> 151 MB. * fix(cli): make the libSQL driver an optional peer so a Postgres-only install skips it @libsql/kysely-libsql was a direct dependency of @metaobjectsdev/cli, so every install carried it and its native addon. The CLI already imports it lazily, only for a sqlite URL on Node, and prints a package-manager-specific install command when it is missing. It is now an optional peer bounded like migrate-ts's, kept as a devDependency for the CLI's own tests. Fresh CLI install with the Biome change: 245 MB -> 101 MB. * no-mistakes(review): Revert libSQL optional-peer change; keep Biome removal * no-mistakes(document): Fix CLI README Biome backend claim
1 parent 8ef0f03 commit 30b2897

8 files changed

Lines changed: 49 additions & 22 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ loaded before stops loading. This vocabulary ships in 1.3.0 with `metamodelVersi
4141
and the `metaobjects-authoring` skill now send grouped totals, dashboard numbers and read-only
4242
report views to `object.report` (`references/declaring-reports.md`) before the `@sql` escape,
4343
which they describe as the last resort for bodies the vocabulary cannot express.
44+
- **`@metaobjectsdev/cli` no longer installs the native Biome binary.** `codegen-ts-react`,
45+
`codegen-ts-tanstack` and the source-only `codegen-ts-angular` declared `@biomejs/biome` as a
46+
peer dependency, which npm installs automatically, so every CLI install carried the ~94 MB
47+
`@biomejs/cli-<platform>` binary that nothing runs: codegen formats through the WebAssembly
48+
build (`@biomejs/wasm-nodejs`). The peer is gone (it stays a devDependency for this repo's own
49+
lint gate), and a fresh npm install of the CLI drops from 245 MB to 151 MB of `node_modules`.
50+
`scripts/check-peer-ranges.ts` now fails a publishable package that requires `@biomejs/biome`
51+
through `dependencies` or a non-optional peer.
4452

4553
### Fixed
4654

‎bun.lock‎

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎scripts/check-peer-ranges.ts‎

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
* version we chose — never the version an adopter would get. This check works because
2626
* it reads MANIFESTS, not `node_modules`, so it needs no network and cannot be fooled
2727
* by a warm lockfile.
28+
*
29+
* Second rule, same walk: no publishable package may REQUIRE the native Biome
30+
* formatter (`@biomejs/biome`, which pulls a ~94 MB per-platform `@biomejs/cli-*`
31+
* binary) through `dependencies` or a non-optional peer. npm installs required peers
32+
* automatically, so a single generator package declaring it put the binary into every
33+
* `@metaobjectsdev/cli` install, though nothing at run time uses it: codegen formats
34+
* through the WebAssembly build (`@biomejs/wasm-nodejs` + `@biomejs/js-api`, see
35+
* `codegen-ts/src/format.ts`). Development use belongs in `devDependencies`; a genuine
36+
* run-time need must be an optional peer (`peerDependenciesMeta`).
2837
*/
2938
import { readdirSync, readFileSync, existsSync } from "node:fs";
3039
import { join } from "node:path";
@@ -35,18 +44,34 @@ const ROOTS = ["server/typescript/packages", "client/web/packages"];
3544
/** A version no real release will reach. If the range still matches, it has no ceiling. */
3645
const BEYOND_ANY_REAL_VERSION = "9999.0.0";
3746

47+
/** The native formatter and its per-platform binaries. */
48+
const isNativeFormatter = (name: string): boolean =>
49+
name === "@biomejs/biome" || name.startsWith("@biomejs/cli-");
50+
3851
interface Violation { pkg: string; peer: string; range: string }
3952
const violations: Violation[] = [];
53+
const nativeFormatter: { pkg: string; dep: string; field: string }[] = [];
4054
let checked = 0;
4155

4256
for (const root of ROOTS) {
4357
for (const dir of readdirSync(join(REPO, root))) {
4458
const manifest = join(REPO, root, dir, "package.json");
4559
if (!existsSync(manifest)) continue;
4660
const pkg = JSON.parse(readFileSync(manifest, "utf8")) as {
47-
name: string; private?: boolean; peerDependencies?: Record<string, string>;
61+
name: string; private?: boolean;
62+
dependencies?: Record<string, string>;
63+
peerDependencies?: Record<string, string>;
64+
peerDependenciesMeta?: Record<string, { optional?: boolean }>;
4865
};
4966
if (pkg.private === true) continue; // never published — its peers bind nobody
67+
for (const dep of Object.keys(pkg.dependencies ?? {})) {
68+
if (isNativeFormatter(dep)) nativeFormatter.push({ pkg: pkg.name, dep, field: "dependencies" });
69+
}
70+
for (const dep of Object.keys(pkg.peerDependencies ?? {})) {
71+
if (isNativeFormatter(dep) && pkg.peerDependenciesMeta?.[dep]?.optional !== true) {
72+
nativeFormatter.push({ pkg: pkg.name, dep, field: "peerDependencies (required)" });
73+
}
74+
}
5075
for (const [peer, range] of Object.entries(pkg.peerDependencies ?? {})) {
5176
checked++;
5277
if (Bun.semver.satisfies(BEYOND_ANY_REAL_VERSION, range)) {
@@ -71,4 +96,15 @@ if (violations.length > 0) {
7196
process.exit(1);
7297
}
7398

99+
if (nativeFormatter.length > 0) {
100+
console.error("✖ native Biome formatter required at install time:\n");
101+
for (const v of nativeFormatter) console.error(` ${v.pkg}\n ${v.field}: "${v.dep}"`);
102+
console.error(
103+
`\nnpm installs it (a ~94 MB native binary) into every adopter's tree, and codegen` +
104+
`\nformats through @biomejs/wasm-nodejs instead. Move it to devDependencies, or, if` +
105+
`\nshipped code really needs it, mark the peer optional in peerDependenciesMeta.\n`,
106+
);
107+
process.exit(1);
108+
}
109+
74110
console.log(`peer-range bounds: OK (${checked} peer ranges, all bounded)`);

‎scripts/check-reference-templates-lint.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ export async function discoverTemplates(repo: string = REPO): Promise<string[]>
7676
return found.sort();
7777
}
7878

79-
/** biome is a dependency of the codegen packages (it runs the `formatTs` pass), so a
80-
* binary is present after `bun install`. Any of them is the same pinned version. */
79+
/** biome is a devDependency of the codegen packages (shipped code formats through the
80+
* WASM build instead), so a binary is present after `bun install`. Any of them is the
81+
* same pinned version. */
8182
export function resolveBiomeBin(repo: string = REPO): string | undefined {
8283
for (const root of PACKAGE_ROOTS) {
8384
const rootDir = join(repo, root);

‎server/typescript/packages/cli/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bun run build:binary # → dist/meta (compiled for the build host's OS/ar
2828
./dist/meta --help
2929
```
3030

31-
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.
31+
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.
3232

3333
### Cross-compiling for other platforms
3434

‎server/typescript/packages/codegen-ts-angular/package.json‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
"@metaobjectsdev/codegen-ts": "workspace:*",
5151
"ts-poet": "^6.10.0"
5252
},
53-
"peerDependencies": {
54-
"@biomejs/biome": ">=1.9.0 <3.0.0"
55-
},
5653
"devDependencies": {
5754
"@biomejs/biome": "^1.9.0",
5855
"bun-types": "latest",

‎server/typescript/packages/codegen-ts-react/package.json‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@
4949
"@metaobjectsdev/codegen-ts": "workspace:*",
5050
"ts-poet": "^6.10.0"
5151
},
52-
"peerDependencies": {
53-
"@biomejs/biome": ">=1.9.0 <3.0.0"
54-
},
5552
"devDependencies": {
5653
"@biomejs/biome": "^1.9.0",
5754
"@metaobjectsdev/test-generators": "workspace:*",

‎server/typescript/packages/codegen-ts-tanstack/package.json‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
"@metaobjectsdev/codegen-ts": "workspace:*",
4949
"ts-poet": "^6.10.0"
5050
},
51-
"peerDependencies": {
52-
"@biomejs/biome": ">=1.9.0 <3.0.0"
53-
},
5451
"devDependencies": {
5552
"@biomejs/biome": "^1.9.0",
5653
"@metaobjectsdev/test-generators": "workspace:*",

0 commit comments

Comments
 (0)