mscdex / mscdex/ssh2

is it possible to avoid circular dependencies?

Open
#1,081 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
5.8k
Forks
734
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am using rollup to bundle the source code which uses ssh2. However the tool complains that ssh2 contains circular dependencies.

Specifically, these files are relevant:

https://github.com/mscdex/ssh2/blob/6b4c64ce5c16f488d90b87997aa0f19c871abe2f/lib/protocol/utils.js#L174

https://github.com/mscdex/ssh2/blob/6b4c64ce5c16f488d90b87997aa0f19c871abe2f/lib/protocol/handlers.js#L5

https://github.com/mscdex/ssh2/blob/6b4c64ce5c16f488d90b87997aa0f19c871abe2f/lib/protocol/kex.js#L1743

Although these lines are valid code in commonjs, is it possible to remove circular dependencies? Potential benefits are avoiding potential bugs and making downstream bundler like rollup webpack work.

Thank you so much! :-)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the dependency relationships around lib/protocol/utils.js:174, lib/protocol/handlers.js:5, and lib/protocol/kex.js:1743, then trace how CommonJS requires form the reported cycle. Done means the relevant circular dependencies are removed without breaking ssh2, and Rollup and webpack no longer report them.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, rollup, webpack
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.