Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<platform>` 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

Expand Down
9 changes: 0 additions & 9 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion scripts/check-peer-ranges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -35,18 +44,34 @@ 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) {
for (const dir of readdirSync(join(REPO, root))) {
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<string, string>;
name: string; private?: boolean;
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
peerDependenciesMeta?: Record<string, { optional?: boolean }>;
};
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)) {
Expand All @@ -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)`);
5 changes: 3 additions & 2 deletions scripts/check-reference-templates-lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ export async function discoverTemplates(repo: string = REPO): Promise<string[]>
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);
Expand Down
2 changes: 1 addition & 1 deletion server/typescript/packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions server/typescript/packages/codegen-ts-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions server/typescript/packages/codegen-ts-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
3 changes: 0 additions & 3 deletions server/typescript/packages/codegen-ts-tanstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
Loading