Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Adds node-fetch as an optional dependency #22

Closed
wants to merge 1 commit into from

Conversation

eoingroat
Copy link

This allows it to import node-fetch in a pnp / yarn berry environment

Otherwise this fails with an error like the following:

fetch-mock tried to access node-fetch (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

As an optionalDependency, and not a peerDependency, it does not have to be satisfied.

This allows it to import node-fetch in a pnp / yarn berry environment
@ljharb
Copy link

ljharb commented Nov 18, 2020

That’s not how optionalDependencies work; those are for things that might fail on install, and should never be set to *.

You may want a peer dep, using peerDependenciesMeta to mark it optional, but tbh this is a design flaw in pnp: presence on disk, not presence in package.json, is how require works.

All that said, it makes zero sense to mock fetch if it’s not in the dep tree, so what i think you actually want here is to list it as both a dep and a (required) peer dep.

@wheresrhys wheresrhys closed this Nov 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants