refactor: simplify YarnNodeModulesCollector by extending NpmNodeModulesCollector#9506
Conversation
…esCollector Yarn Classic (v1) produces a hoisted node_modules structure similar to npm. Instead of implementing custom NDJSON parsing logic, we now leverage NpmNodeModulesCollector's existing implementation using npm list command. This follows the same pattern as YarnBerryNodeModulesCollector. Changes: - Reduce yarnNodeModulesCollector.ts from ~268 lines to ~25 lines - Remove unused YarnDependency and YarnBerryDependency types Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 06ec44c The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR refactors YarnNodeModulesCollector to extend NpmNodeModulesCollector instead of implementing custom NDJSON parsing logic, recognizing that Yarn Classic (v1) produces a hoisted node_modules structure similar to npm. This follows the pattern established by YarnBerryNodeModulesCollector and is a follow-up to PR #9443 which enabled npm list to work on yarn berry and bun project setups.
Changes:
- Simplified
YarnNodeModulesCollectorby extendingNpmNodeModulesCollectorand delegating to npm list command - Removed unused
YarnDependencyandYarnBerryDependencytype definitions from types.ts - Reduced yarnNodeModulesCollector.ts from ~268 lines to ~25 lines by removing custom parsing logic
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/app-builder-lib/src/node-module-collector/yarnNodeModulesCollector.ts | Refactored to extend NpmNodeModulesCollector with minimal overrides for manager, lockfile, isHoisted, getDependenciesTree, and isProdDependency |
| packages/app-builder-lib/src/node-module-collector/types.ts | Removed unused YarnDependency and YarnBerryDependency type definitions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
If this works consistently, then I'm going to be so dam sad and happy at the same time. Sad because that was a ton of dev days put into it; happy because of the new implementation's simplicity haha. |
|
Big snapshot failures. Some could be false positives, hard to say since the snapshot diff is so big. This does stick out to me as a red flag, though, as it'll break the app at runtime |
This has always been working fine. The node modules for yarn 1 are the same as npm, and electron-builder always been using |
The snapshot inside node-mac-permissions already has snapshots of these two packages |
|
I manually checked it, and the previous snapshot had duplicate bindings and node-addon-api. Using |
Update outdated snapshots for yarn parse-asn1, yarn multi-package workspace, and yarn workspace tests after YarnNodeModulesCollector refactoring. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The previous commit incorrectly deleted Windows and other platform snapshots when running tests on macOS. This restores those snapshots. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Yarn Classic (v1) produces a hoisted node_modules structure similar to npm. Instead of implementing custom NDJSON parsing logic, we now leverage NpmNodeModulesCollector's existing implementation using npm list command.
This follows the same pattern as YarnBerryNodeModulesCollector.
Changes:
npm listto work on yarn berry and bun project setups #9443