-
Notifications
You must be signed in to change notification settings - Fork 20
fix(yarn): patch yarn.lock for link: dependencies and fix extraction path #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
a140c5f to
8cb1ccf
Compare
e7f4f8e to
ff1eb1a
Compare
…path Problem 1: Leeway patches package.json for link: dependencies but wasn't consistently patching yarn.lock. This caused yarn install to fail with --frozen-lockfile because the lockfile didn't match package.json. Problem 2: When extracting YarnApp dependencies to _link_deps/<pkg>/, the --strip-components=2 was incorrect. It stripped './node_modules/' but left '<pkg>/' resulting in _link_deps/<pkg>/<pkg>/. Changed to --strip-components=3 to strip './node_modules/<pkg>/' completely. Also handle path normalization: package.json may have 'link:./../shared' while yarn.lock normalizes it to 'link:../shared'. Co-authored-by: Ona <no-reply@ona.com>
Add integration test TestYarnPackage_LinkDependencies_Integration that creates a monorepo with link: dependencies and verifies the build succeeds with --frozen-lockfile. Add unit tests for extractNpmPackageNames() covering YarnLibrary and YarnApp tarball formats, scoped packages, and edge cases. Co-authored-by: Ona <no-reply@ona.com>
Lower the speedup threshold from 1.0 to 0.75 for small package counts (< 50). With small package counts, batch overhead can occasionally make it slower than sequential, causing flaky test failures. Co-authored-by: Ona <no-reply@ona.com>
Add unit test TestYarnAppExtraction_ScopedPackage demonstrating that: - Non-scoped packages work with --strip-components=3 - Scoped packages fail with --strip-components=3 (the bug) - Scoped packages work with --strip-components=4 (the fix) Add integration test TestYarnPackage_ScopedLinkDependencies_Integration for end-to-end testing of scoped package link: dependencies. Co-authored-by: Ona <no-reply@ona.com>
Scoped npm packages (e.g., @scope/pkg) have an extra path component in the tarball structure. The extraction command now uses --strip-components=4 for scoped packages instead of 3. Path components: - Non-scoped: ./node_modules/pkg/ (3 components) - Scoped: ./node_modules/@scope/pkg/ (4 components) Co-authored-by: Ona <no-reply@ona.com>
ff1eb1a to
7eed8b0
Compare
geropl
approved these changes
Dec 5, 2025
Member
geropl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ to unblock
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.
Description
This PR adds support for yarn packages that use
link:dependencies in monorepo setups when building with--frozen-lockfile.Fixes https://linear.app/ona-team/issue/PDE-180/build-failures-with-frozen-lockfile
Problem:
link:dependencies break with--frozen-lockfileYarn's
link:protocol references local packages via relative paths (e.g.,"shared-lib": "link:../shared"). These paths are relative to the source directory, but leeway builds run in an isolated build directory where those paths don't exist.Before
--frozen-lockfilewas introduced,yarn installwould resolve these broken paths and update the lockfile. After introducing--frozen-lockfile(commit 3bf13c6), yarn refuses to install because the lockfile doesn't match the actual dependency resolution.Solution
When building a yarn package that has
link:dependencies on other leeway yarn packages:_link_deps/<pkg>/in the build directorylink:../pathwithfile:./_link_deps/<pkg>--frozen-lockfile)Tarball structures
Leeway produces two types of yarn tarballs depending on the
packagingconfig:YarnLibrary (
packaging: library, usesyarn pack):YarnApp (
packaging: archive, default):The extraction uses
--strip-componentswith an explicit path filter to handle each case:tar -xzf $tarball -C _link_deps/$pkg --strip-components=1 package/tar -xzf $tarball -C _link_deps/$pkg --strip-components=3 ./node_modules/$pkg/@scope/pkg):tar -xzf $tarball -C _link_deps/$pkg --strip-components=4 ./node_modules/@scope/$pkg/Implementation details
extractNpmPackageNames()to discover npm package names from built tarballs (needed because leeway package names likeshared-lib:libdon't match npm names likegitpod-shared)link:./../sharedvslink:../shared)@gitpod/utils) which have an extra path component in the tarball structureChanges
pkg/leeway/build.go: Add link: dependency handling for yarn packagespkg/leeway/build_internal_test.go: Add unit tests for scoped package extractionpkg/leeway/build_integration_test.go: Add integration testTesting
Added integration test
TestYarnPackage_LinkDependencies_Integrationthat:link:../shared-lib--frozen-lockfileAdded unit test
TestYarnAppExtraction_ScopedPackagethat verifies:--strip-components=3@test/utils) extract correctly with--strip-components=4Also tested manually with
gitpod-nextvscode packages:Both builds succeed with this PR.