From a25c489e27367523f28dcc384a737d25ca74a387 Mon Sep 17 00:00:00 2001 From: foxxyz Date: Thu, 17 Sep 2020 20:46:07 -0700 Subject: [PATCH 1/2] docs: add section on peerDependenciesMeta field in package.json (fixes #1247) --- docs/content/configuring-npm/package-json.md | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/content/configuring-npm/package-json.md b/docs/content/configuring-npm/package-json.md index c58fde7923218..6232551469f65 100644 --- a/docs/content/configuring-npm/package-json.md +++ b/docs/content/configuring-npm/package-json.md @@ -718,6 +718,30 @@ the host package's major version will break your plugin. Thus, if you've worked with every 1.x version of the host package, use `"^1.0"` or `"1.x"` to express this. If you depend on features introduced in 1.5.2, use `">= 1.5.2 < 2"`. +### peerDependenciesMeta + +When a user installs a your package, npm will emit warnings if packages specified in `peerDependencies` are not already installed. The `peerDependenciesMeta` field serves to provide npm more information on how your peer dependencies are to be used. Specifically, it allows peer dependencies to be marked as optional. + +For example: + +```json +{ + "name": "tea-latte", + "version": "1.3.5", + "peerDependencies": { + "tea": "2.x", + "soy-milk": "1.2" + }, + "peerDependenciesMeta": { + "soy-milk": { + "optional": true + } + } +} +``` + +Marking a peer dependency as optional ensures npm will not emit a warning if the `soy-milk` package is not installed on the host. This allows you to integrate and interact with a variety of host packages without requiring all of them to be installed. + ### bundledDependencies This defines an array of package names that will be bundled when publishing From 238287d78c41196208a87b0d1b35227aec3b153c Mon Sep 17 00:00:00 2001 From: foxxyz Date: Sun, 20 Sep 2020 20:13:54 -0700 Subject: [PATCH 2/2] docs: typo (a your => your) --- docs/content/configuring-npm/package-json.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/configuring-npm/package-json.md b/docs/content/configuring-npm/package-json.md index 6232551469f65..90ae4f403c969 100644 --- a/docs/content/configuring-npm/package-json.md +++ b/docs/content/configuring-npm/package-json.md @@ -720,7 +720,7 @@ this. If you depend on features introduced in 1.5.2, use `">= 1.5.2 < 2"`. ### peerDependenciesMeta -When a user installs a your package, npm will emit warnings if packages specified in `peerDependencies` are not already installed. The `peerDependenciesMeta` field serves to provide npm more information on how your peer dependencies are to be used. Specifically, it allows peer dependencies to be marked as optional. +When a user installs your package, npm will emit warnings if packages specified in `peerDependencies` are not already installed. The `peerDependenciesMeta` field serves to provide npm more information on how your peer dependencies are to be used. Specifically, it allows peer dependencies to be marked as optional. For example: