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

Nodegit should be an optional peer dependency #105

Open
Adjective-Object opened this issue Jan 19, 2022 · 8 comments
Open

Nodegit should be an optional peer dependency #105

Adjective-Object opened this issue Jan 19, 2022 · 8 comments

Comments

@Adjective-Object
Copy link
Collaborator

Adjective-Object commented Jan 19, 2022

When nodegit fails to install (e.g. on node 16+ on a system without the dependencies for libgit2), requiring good-fences at all fails with this require stack:

  requireStack: [
    'node_modules/nodegit/dist/nodegit.js',
    'node_modules/good-fences/lib/utils/diffing/getFenceAndImportDiffsFromGit.js',
    'node_modules/good-fences/lib/core/runner.js',
    'node_modules/good-fences/lib/index.js',
  ]

This is because we import nodegit even when it is not being used.

We can work around this by making it an optional dependency and importing the module only when partial diff functionality is actually used (e.g. runtime require())

@Adjective-Object
Copy link
Collaborator Author

Adjective-Object commented Jan 31, 2022

Should we consider migrating to wasm-git instead?

@gustaff-weldon
Copy link

@Adjective-Object @smikula if switching to wasm-git bodes better when it comes to compilation issues, please consider moving on to it.
The nodegit compilation errors are plaguing our CI and docker setup. We had to enforce alpha nodegit release via yarn resolutions to be able to install good-fences on Macs (x86). Now, we started getting errors on alpine linux with Node 16...

@tianhuil
Copy link

tianhuil commented Apr 3, 2023

@smikula: do you know if there's any progress on this? We would love to use good-fences, but the node-git issues are causing issues installing on our Github CI and keeping us from using good-fences.

@smikula
Copy link
Owner

smikula commented Apr 6, 2023

@Adjective-Object, is this something that would be easy to take care of? I know we're not really using this version of good-fences anymore, but I'd like to make sure it remains useful for other people.

@tianhuil, if you aren't aware, we've reimplemented good-fences in rust for a much faster experience. You might find that moving to that solves your problem and gets better performance.

@tianhuil
Copy link

Thank you @smikula! Should you put a warning on the README.md if that's the recommended version?

@gustaff-weldon
Copy link

Thank you @smikula! Should you put a warning on the README.md if that's the recommended version?

@smikula I second that, I was not aware there's a reimplementation also distributed via npm, so looks like an easy replacement .

Are you going to add support in the new version for blacklisting, ie. listing dependencies that module is not allowed to use? That would be very useful for cases where we want to prevent people from importing certain code we do not want them to rely on.

CraigMacomber added a commit to microsoft/FluidFramework that referenced this issue May 11, 2023
## Description

Make good-fences a dev dep in examples/external-data since its only use
by package scripts.
Replace nodegit with an empty package since we only depend on it via
good-fences, and we do not require that part of its feature set.

This works around good-fences not making it an optional dep (
smikula/good-fences#105 ).

https://github.com/Adjective-Object/good-fences-rs-core was also tried,
but our use cases are impacted by
Adjective-Object/good-fences-rs-core#46 so it
does not work for us.

This results in many deps becoming dev only, and many being removed.
`nodegit` is particularly nice to remove since its a native module has
issues rebuilding when nodejs is updated.
@tianhuil
Copy link

The nodegit issue can be solved by setting

{ 
  "overrides": {
	"nodegit": "npm:empty-npm-package@1.0.0"
  }
}

See microsoft/FluidFramework#15572 . Credit due to @CraigMacomber

@wawyed
Copy link

wawyed commented Aug 30, 2023

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants