diff options
Diffstat (limited to 'deps/npm/doc/files/package.json.md')
-rw-r--r-- | deps/npm/doc/files/package.json.md | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/deps/npm/doc/files/package.json.md b/deps/npm/doc/files/package.json.md index c987948b4c..b9b05d4d4d 100644 --- a/deps/npm/doc/files/package.json.md +++ b/deps/npm/doc/files/package.json.md @@ -311,6 +311,7 @@ See semver(7) for more details about specifying version ranges. * `<version` * `<=version` * `~version` "Approximately equivalent to version" See semver(7) +* `^version` "Compatible with version" See semver(7) * `1.2.x` 1.2.0, 1.2.1, etc., but not 1.3.0 * `http://...` See 'URLs as Dependencies' below * `*` Matches any version @@ -404,6 +405,40 @@ can consume the functionality without requiring them to compile it themselves. In dev mode (ie, locally running `npm install`), it'll run this script as well, so that you can test it easily. +## peerDependencies + +In some cases, you want to express the compatibility of your package with an +host tool or library, while not necessarily doing a `require` of this host. +This is usually refered to as a *plugin*. Notably, your module may be exposing +a specific interface, expected and specified by the host documentation. + +For example: + + { + "name": "tea-latte", + "version": "1.3.5" + "peerDependencies": { + "tea": "2.x" + } + } + +This ensures your package `tea-latte` can be installed *along* with the second +major version of the host package `tea` only. The host package is automatically +installed if needed. `npm install tea-latte` could possibly yield the following +dependency graph: + + ├── tea-latte@1.3.5 + └── tea@2.2.0 + +Trying to install another plugin with a conflicting requirement will cause an +error. For this reason, make sure your plugin requirement is as broad as +possible, and not to lock it down to specific patch versions. + +Assuming the host complies with [semver](http://semver.org/), only changes in +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"`. + ## bundledDependencies Array of package names that will be bundled when publishing the package. |