How to make npm resolve dependency dependency on another package?

TL DR: How can I change one of the package dependency dependencies with another package? For example, I want to change package B dependencies of package A as package C, but only for package A (i.e. I do not want to change the dependencies of package A upstream).


I am writing a plugin for Leaflet . The flyer is available as an NPM package (and my plugin will also be when I finish). There is also another plugin that extends my plugin, Esri-Leaflet , which has a leaflet as a dependency.

My plugin uses Mocha / Chai / Sinon as a test environment for my code. I run these tests using an NPM script both during development and as part of the CI.

When I run the tests that depend on the Leaflet, I have a number of errors, because, unfortunately, the Leaflet depends on the number of global variables that are not available in the headless node environment (for example, window). Fortunately, there is an alternative package that was offered to me under the name leaflet-headless , which addresses these problems (actually it’s quite interesting to see if you are interested).

Is there a way, just for my package, to tell NPM to use a leaflet without a header using Leaflet when resolving Esri-Leaflet dependencies? That is, I either want to remove Leaflet-dependent information (because my project already depends on a headless leaf), or change it to no elevators.

I looked npm shrinkwrap, but it looks like it can only indicate version numbers, and not change the actual package dependencies.

If NPM does not have the ability to do what I ask, can you recommend an alternative solution? I am already studying the fixation of global dependency in Leaflet upstream to eliminate the need for headless flyers.

+4
source share
1 answer

Node, Node 8 .

, fork ( leaflet-headlessLeaflet).

, , . json

dependencies: {
    "Leaflet": "username/Leaflet"
}

package-lock.json, , Esri-Leaflet github, Leaflet .

0

Source: https://habr.com/ru/post/1681294/


All Articles