Repository navigation
fix(@angular/cli): support resolving subproject dependencies in bun workspaces - #34533
Conversation
…orkspaces When running `bun pm ls` inside a workspace member directory, Bun resolves the workspace root lockfile and outputs only the direct dependencies declared in the root `package.json`, along with `workspace:` references to member packages. Because subproject dependencies (such as `@angular/core`) are omitted from this output, commands like `ng update` and `ng add` fail to detect installed project dependencies when executed in a Bun workspace member. To resolve this, `parseBunDependencies` now ignores `workspace:` protocol entries, and the `bun` package manager descriptor enables `requiresManifestDependencyLookup`. When populating the dependency cache, `PackageManager` supplements the command output by reading `dependencies` and `devDependencies` from the working directory's `package.json` and resolving their installed manifests across ancestor `node_modules` directories up to the workspace lockfile or repository root. Additionally, `getPackageNameCommand` is configured for `bun` using `bun pm pkg get name` to provide the same CLI fallback as `npm` and `pnpm`. Fixes angular#34402
Unlike npm, `bun pm view` does not emit `npm ERR! code E404` or nested JSON error objects with a `code` property when a package, version, or dist-tag is missing from the registry. Instead, missing packages produce plain-text HTTP status lines on `stderr` (such as `404 Not Found: ...`), while missing versions or dist-tags produce flat JSON objects on `stdout` with a string `error` field (such as `{ "error": "No matching version found" }`). Because `parseNpmLikeError` did not recognize either format, querying a non-existent package or version under Bun threw an unhandled `PackageManagerError` instead of returning `null`.
This change introduces a dedicated `parseBunError` parser for the `bun` package manager descriptor that extracts structured error codes from both Bun's JSON error payloads and plain-text HTTP status messages, normalizing not-found responses to `E404`.
There was a problem hiding this comment.
Code Review
This pull request introduces a manifest-based dependency resolution mechanism to supplement package manager commands, specifically addressing limitations in bun pm ls where workspace member dependencies are not fully reported. It adds directory traversal logic to locate node_modules up to a lockfile or git root, implements Bun-specific error parsing, and updates corresponding tests. The review feedback suggests extending the dependency resolution logic to also scan optionalDependencies from package.json to ensure complete coverage.
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
When running
bun pm lsinside a workspace member directory, Bun resolves the workspace root lockfile and outputs only the direct dependencies declared in the rootpackage.json, along withworkspace:references to member packages. Because subproject dependencies (such as@angular/core) are omitted from this output, commands likeng updateandng addfail to detect installed project dependencies when executed in a Bun workspace member.To resolve this,
parseBunDependenciesnow ignoresworkspace:protocol entries, and thebunpackage manager descriptor enablesrequiresManifestDependencyLookup. When populating the dependency cache,PackageManagersupplements the command output by readingdependenciesanddevDependenciesfrom the working directory'spackage.jsonand resolving their installed manifests across ancestornode_modulesdirectories up to the workspace lockfile or repository root. Additionally,getPackageNameCommandis configured forbunusingbun pm pkg get nameto provide the same CLI fallback asnpmandpnpm.Fixes #34402