fix: resolve optionally declared upstream assets from the machine package root - #208
Merged
Merged
Conversation
fonts-open declares 109 bundled @fontsource assets in optionalDependencies, but declaredExternalPackageRoot read only dependencies, so every documented 'hypit packages install <name>@<version>' repair left the asset unreachable. Read optionalDependencies as the fallback and cover it with a locator test.
Member
|
Thank you for the report and the fix. Reproduced on the published 0.1.10 distribution (macOS, outside any checkout), following the CLI's own repair instruction: Applying this change to that same installed distribution and toggling it back and forth attributes the behavior to the one lookup:
Your claim that Linux and Windows checks pass. Merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #206
What this fixes
fonts-opendeclares all 109 bundled@fontsource*assets inoptionalDependencies, because a Distribution ships them from the machine package root rather than through its ownnode_modules.declaredExternalPackageRootread onlydependencies, so the version lookup always returnedundefinedand the asset was reported as missing even right after a successful install:The documented repair therefore never converged. This change falls back to
optionalDependencieswhen the manifest does not list the name underdependencies.Only an npm install exposes the bug. A contributor checkout links the fonts into
packages/fonts-open/node_modules, andlocateNodePackagereturns from itsnearbyshort circuit before reaching the external branch.The change
Scope
location.tsL84-85 is the only place in the repository that readsdependenciesto select an external package version (verified by grep), so this is one lookup, not a refactor.dependenciesstill wins when a name appears in both, so no existing resolution order changes.Test evidence
New regression case in
packages/package-loader-node/test/location.test.ts:$ node --import tsx --test packages/package-loader-node/test/location.test.ts # tests 4 · pass 4 · fail 0It fails on the unmodified source, which is what makes it a regression test:
End-to-end effect against a real npm Distribution Layout:
declaredExternalPackageRoot(<machine root>, <npm fonts-open/src/surface.ts>, "@fontsource-variable/inter")undefined<HYPIT_STATE_HOME>/packages/@fontsource-variable/inter/5.3.0locateNodePackage(...)FAILED: cannot locate installed packageLOCATED …/node_modules/@fontsource-variable/interVerification
pnpm check(repo-widetsc --noEmit) — passes on this branch.pnpm test— unchanged; the single failure is a pre-existing WindowsEPERMinpackages/compiler-node/test/compiler.test.tswhen it creates a symlink escape sample. It reproduces on pristinemainwith this change stashed, and needs developer mode or an elevated shell.This PR is independent of the Distribution child-process resolver fix (#207); the two touch disjoint files.