Skip to content
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

chore: refactor node module collector, extract explicit DependencyTree, update types #8872

Merged
merged 18 commits into from
Feb 20, 2025

Conversation

mmaietta
Copy link
Collaborator

@mmaietta mmaietta commented Feb 18, 2025

  • Moves functions around so that they're topologically ordered.
  • Updates types for explicit usage of what is the result JSON.parse and what is used for the production tree
  • Removes delete array[key] logic by refactoring to reduce (no more modifying the original JSON.parse tree)
  • Extracts JSON.parse functionality to be specific to each collector
  • Extracts DependencyTree with initial set implicitDependenciesInjected = false so that the boolean isn't optional by using DFS approach
  • Consolidates implicit dependency injection to npm-specific logic by extracting simplified dependency tree w/o dependencies
  • Converted the abstract collector class to be generic of type: NodeModulesCollector<T extends Dependency<T, OptionalsType>, OptionalsType>
    • This way, all abstracted and overridden methods are easily typed per their respective JSON.parse objects. Then uses a common method to construct the dependencies into a DependencyTree and then internally (as before) hoisting and converting to NodeModuleInfo[]
    • This accommodates the differences of optionalDependencies within pnpm list (PnpmDependency) and npm list (string)

Copy link

changeset-bot bot commented Feb 18, 2025

🦋 Changeset detected

Latest commit: 91165b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Patch
dmg-builder Patch
electron-builder-squirrel-windows Patch
electron-builder Patch
electron-forge-maker-appimage Patch
electron-forge-maker-nsis-web Patch
electron-forge-maker-nsis Patch
electron-forge-maker-snap Patch

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

@mmaietta mmaietta force-pushed the refactor-node-module-collector-3 branch from 0683e8e to 1897be4 Compare February 19, 2025 06:15
…ave different formats for `optionalDependencies`. make NodeModulesCollector into generic so that parse logic is consolidated to each subclass. add in optional deps just in case since we filter anything out that isn't in _dependencies in the subsequent reduce.
@mmaietta mmaietta force-pushed the refactor-node-module-collector-3 branch from 96b1120 to f89179c Compare February 19, 2025 07:25
beyondkmp
beyondkmp previously approved these changes Feb 20, 2025
@beyondkmp
Copy link
Collaborator

Great Job!!!

@mmaietta mmaietta merged commit 7f6c3fe into master Feb 20, 2025
17 checks passed
@mmaietta mmaietta deleted the refactor-node-module-collector-3 branch February 20, 2025 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants