Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How do I make a node package with an optional peerDependency it depends on in test code?

$
0
0

The official documentation for peerDependency's says (emphasis mine):

A plugin package is meant to be used with another "host" package, even though it does not always directly use the host package.

I've got a situation where my plugin does use the host package directly (in a test), even though this peerDependency is meant to be optional for the app. This is the relationship I want between these packages:

App --may depend on, but may not--> canvasMy package --optional peer dependency--> canvasMy package tests --depends on--> canvas

How should my package.json be written for this? Here's what I've currently got, and I think it works?

{  // ..."devDependencies": {"canvas": "^2.11.2"  },"peerDependencies": {"canvas": "^2.11.2","jsdom": "^24.0.0"  },"peerDependenciesMeta": {"canvas": {"optional": true    }  }}

Is this the correct way to write a package.json with an optional peerDependency that it uses in test code?


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>