From e6878a3629143bde9f50cc0a125ba1f9cebda189 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 18 Nov 2026 01:14:34 +0000 Subject: [PATCH 1/2] fix: give every tool babylon's manifests as committed add-workspace-protocol.js rewrote babylon's plain sibling ranges to `workspace:*`, in vlt's setup only. vlt 1.8 does that rewrite itself on install (--migrate-workspaces is on by default), so the script now only handed vlt an adjusted project. Drop it; clean_workspace_protocol still restores the manifests vlt migrates. pnpm's registry lookups for siblings are its own default: with plain ranges it queries the registry for each one (240 lookups cold, 223 of them 404) before linking it, and with `workspace:*` it makes none. linkWorkspacePackages is read by pnpm 12. METHODOLOGY now says how each tool handles babylon's siblings. Fixes #210 Co-Authored-By: Claude Opus 5.5 --- docs/FIXTURES/BABYLON.md | 5 ++ docs/METHODOLOGY.md | 16 ++++ suite/scripts/add-workspace-protocol.js | 106 ------------------------ suite/scripts/clean-helpers.sh | 3 + suite/scripts/variations/common.sh | 2 +- 5 files changed, 25 insertions(+), 107 deletions(-) delete mode 100644 suite/scripts/add-workspace-protocol.js diff --git a/docs/FIXTURES/BABYLON.md b/docs/FIXTURES/BABYLON.md index c49327471b1..3445f831524 100644 --- a/docs/FIXTURES/BABYLON.md +++ b/docs/FIXTURES/BABYLON.md @@ -20,6 +20,11 @@ from installing a wide flat graph. It is the fixture that catches a tool handlin It is also the only fixture whose own `vlt.json` declares workspaces. +Its 323 references between workspace packages are plain semver ranges, not +`workspace:`, and every tool gets them as committed. See +[METHODOLOGY](../METHODOLOGY.md#what-a-benchmark-is-here) for how each tool +links them. + ## Variations All install variations. No `build`, `build-cache` or `run`. diff --git a/docs/METHODOLOGY.md b/docs/METHODOLOGY.md index 1e0addf113e..346e4d27fc1 100644 --- a/docs/METHODOLOGY.md +++ b/docs/METHODOLOGY.md @@ -46,6 +46,22 @@ vlt can also be pointed at `registry.npmjs.org`; these numbers don't measure that. The `registry-*` variations are the ones that hold the client constant and compare registries. +Fixtures are installed as committed, with the same manifests for every tool. +In `babylon`, workspace packages depend on each other by plain semver range +(`"@dev/core": "^1.0.0"`), not `workspace:`, and each tool links them its own +way: + +- vlt rewrites those ranges to `workspace:*` in `package.json` on its first + install. That rewrite is part of its timed run wherever the manifests start + out unmigrated, such as `clean`. +- pnpm links them (the fixture's `pnpm-workspace.yaml` sets + `linkWorkspacePackages: true`), but first asks the registry for each one: + about 240 lookups per cold install, most answered 404 for private packages. + It also installs `@babylonjs/shared-ui-components`, a peer dependency, from + the registry. +- Every tool downloads `babylonjs-gltf2interface@6` from the registry, because + `packages/tools/devHost` asks for `^6.42.0` and the workspace has 8.49.6. + vlt finishes some work in detached processes that keep running after the `vlt` command exits: unpacking fetched tarballs into its cache (about 19 seconds after a cold `babylon` install), revalidating cached manifests, diff --git a/suite/scripts/add-workspace-protocol.js b/suite/scripts/add-workspace-protocol.js deleted file mode 100644 index 9c7fa96e1b9..00000000000 --- a/suite/scripts/add-workspace-protocol.js +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env node - -/** - * Adds `workspace:` protocol prefix to inter-workspace dependency specs. - * - * Some package managers (like vlt) require the `workspace:` protocol to - * resolve workspace packages, while others (like npm, yarn classic) do it - * automatically by matching package names. This script bridges that gap by - * rewriting dependency specs for workspace packages. - * - * Uses `workspace:*` to match any local version, since workspace packages - * in monorepos often have cross-references where the semver range in the - * dep spec may not strictly match the current local version. - * - * Usage: node scripts/add-workspace-protocol.js [fixture-path] - * - * If no fixture-path is given, uses the current directory. - */ - -import { readFileSync, writeFileSync, existsSync } from 'node:fs' -import { join, resolve } from 'node:path' -import { execSync } from 'node:child_process' - -const fixtureRoot = resolve(process.argv[2] || '.') - -// Read root package.json to get workspace globs -const rootPkgPath = join(fixtureRoot, 'package.json') -if (!existsSync(rootPkgPath)) { - console.error(`No package.json found at ${rootPkgPath}`) - process.exit(1) -} - -const rootPkg = JSON.parse(readFileSync(rootPkgPath, 'utf8')) -const workspaceGlobs = rootPkg.workspaces || [] - -if (workspaceGlobs.length === 0) { - console.log('No workspaces defined, nothing to do.') - process.exit(0) -} - -// Find all workspace package.json files -const findCmd = `find ${fixtureRoot}/packages -name package.json -not -path '*/node_modules/*'` -const packageJsonPaths = execSync(findCmd, { encoding: 'utf8' }) - .trim() - .split('\n') - .filter(Boolean) - -// Also include the root package.json -packageJsonPaths.push(rootPkgPath) - -// Build a set of workspace package names -const workspacePackageNames = new Set() -for (const pkgPath of packageJsonPaths) { - try { - const pkg = JSON.parse(readFileSync(pkgPath, 'utf8')) - if (pkg.name) { - workspacePackageNames.add(pkg.name) - } - } catch { - // skip malformed files - } -} - -console.log(`Found ${workspacePackageNames.size} workspace packages`) - -// Now rewrite all package.json files -const depFields = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'] -let modifiedCount = 0 - -for (const pkgPath of packageJsonPaths) { - try { - const raw = readFileSync(pkgPath, 'utf8') - const pkg = JSON.parse(raw) - let modified = false - - for (const field of depFields) { - const deps = pkg[field] - if (!deps) continue - - for (const [name, spec] of Object.entries(deps)) { - if ( - workspacePackageNames.has(name) && - typeof spec === 'string' && - !spec.startsWith('workspace:') - ) { - // Use workspace:* to always resolve to the local version - // regardless of what semver range was originally specified - deps[name] = 'workspace:*' - modified = true - } - } - } - - if (modified) { - // Preserve the original formatting - const indent = raw.match(/^(\s+)"/m)?.[1] || ' ' - const newline = raw.endsWith('\n') ? '\n' : '' - writeFileSync(pkgPath, JSON.stringify(pkg, null, indent) + newline) - modifiedCount++ - } - } catch { - // skip malformed files - } -} - -console.log(`Modified ${modifiedCount} package.json files to add workspace: protocol`) diff --git a/suite/scripts/clean-helpers.sh b/suite/scripts/clean-helpers.sh index 55e8cdfd3d2..30ffe9200eb 100644 --- a/suite/scripts/clean-helpers.sh +++ b/suite/scripts/clean-helpers.sh @@ -271,6 +271,9 @@ clean_git() { fi } +# vlt rewrites plain ranges that link a workspace sibling to `workspace:*` +# (on `babylon`, 80 package.json files) on its first install. Restore the +# fixture's manifests so the next tool starts from the project as committed. clean_workspace_protocol() { echo "Restoring package.json files (undo workspace: protocol changes)..." if command -v git &> /dev/null && git rev-parse --git-dir > /dev/null 2>&1; then diff --git a/suite/scripts/variations/common.sh b/suite/scripts/variations/common.sh index 36577df63ac..d1b8dca2bfe 100644 --- a/suite/scripts/variations/common.sh +++ b/suite/scripts/variations/common.sh @@ -75,7 +75,7 @@ BENCH_SETUP_BERRY="touch yarn.lock; echo \"$BENCH_COMMAND_YARN_MODERN_CONFIG\" > BENCH_SETUP_ZPM="touch yarn.lock; echo \"$BENCH_COMMAND_YARN_MODERN_CONFIG\" > .yarnrc.yml; { echo '[zpm prepare]'; echo 'cwd:'; pwd; echo 'package.json:'; ls -la package.json || true; echo 'yarn path:'; command -v yarn || true; echo 'yarn version:'; yarn -v || true; echo 'canary version:'; echo \"$BENCH_ZPM_VERSION\"; echo 'packageManager (before):'; npm pkg get packageManager || true; echo 'set packageManager=yarn@'"$BENCH_ZPM_VERSION"':' ; npm pkg set packageManager=\"yarn@$BENCH_ZPM_VERSION\" || true; echo 'packageManager (after):'; npm pkg get packageManager || true; } >> $BENCH_OUTPUT_FOLDER/zpm-prepare.log 2>&1" BENCH_SETUP_PNPM="npm pkg delete packageManager >/dev/null 2>&1 || true" -BENCH_SETUP_VLT="node $BENCH_SCRIPTS/add-workspace-protocol.js . >> $BENCH_OUTPUT_FOLDER/vlt-prepare.log 2>&1" +BENCH_SETUP_VLT="" BENCH_SETUP_BUN="" BENCH_SETUP_DENO="" BENCH_SETUP_AUBE="npm pkg delete packageManager >/dev/null 2>&1 || true" From ae6b983b7e405ea499508399a040c393a9ad54d7 Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 18 Nov 2026 03:26:19 +0000 Subject: [PATCH 2/2] docs: describe vlt's partial migration on babylon (vltpkg/vltpkg#2154) vlt 1.8.0 rewrites 257 of babylon's 323 sibling specs; the 66 exact/peer specs on @babylonjs/* stay as-is, and about half of cold installs resolve four of them to registry copies. Only `clean` times the migration. Co-Authored-By: Claude Opus 5.5 --- docs/FIXTURES/BABYLON.md | 2 +- docs/METHODOLOGY.md | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/docs/FIXTURES/BABYLON.md b/docs/FIXTURES/BABYLON.md index 3445f831524..3c964d4a9c7 100644 --- a/docs/FIXTURES/BABYLON.md +++ b/docs/FIXTURES/BABYLON.md @@ -16,7 +16,7 @@ and slowest fixture in the suite. **Workspace resolution at scale.** Every other fixture is a single package; this one is 86 of them with internal cross-dependencies, which is a different problem from installing a wide flat graph. It is the fixture that catches a tool handling -`workspace:` protocol specifiers, hoisting, or link topology badly. +cross-workspace ranges, hoisting, or link topology badly. It is also the only fixture whose own `vlt.json` declares workspaces. diff --git a/docs/METHODOLOGY.md b/docs/METHODOLOGY.md index 346e4d27fc1..d319d985edb 100644 --- a/docs/METHODOLOGY.md +++ b/docs/METHODOLOGY.md @@ -46,14 +46,22 @@ vlt can also be pointed at `registry.npmjs.org`; these numbers don't measure that. The `registry-*` variations are the ones that hold the client constant and compare registries. -Fixtures are installed as committed, with the same manifests for every tool. +Fixtures are installed as committed, with the same dependency specs for every +tool (berry and zpm still get their `packageManager` pin and `.yarnrc.yml`). In `babylon`, workspace packages depend on each other by plain semver range (`"@dev/core": "^1.0.0"`), not `workspace:`, and each tool links them its own way: -- vlt rewrites those ranges to `workspace:*` in `package.json` on its first - install. That rewrite is part of its timed run wherever the manifests start - out unmigrated, such as `clean`. +- vlt rewrites most of those ranges (257 of 323) to `workspace:*` in + `package.json` on its first install. That rewrite is part of its timed run + wherever the manifests start out unmigrated, which is `clean`; in the other + variations the untimed first warmup migrates them. vlt 1.8.0 leaves the 66 + exact and peer specs on the published `@babylonjs/*` names as they are, and + in about half of cold installs it resolves four of them (`gui`, `loaders`, + `materials`, `serializers`) to registry copies instead of the workspace, + downloading 4 extra tarballs ([vltpkg/vltpkg#2154](https://github.com/vltpkg/vltpkg/issues/2154)). + So vlt's `babylon` `clean` results can differ between runs until that is + fixed. - pnpm links them (the fixture's `pnpm-workspace.yaml` sets `linkWorkspacePackages: true`), but first asks the registry for each one: about 240 lookups per cold install, most answered 404 for private packages.