npmPeer

abstract fun npmPeer(name: String, version: String)

Declares a dependency on a NPM module that is added to peerDependencies.

NPM peer dependencies should not be applied to Gradle dependency scopes such as api, implementation, and so on. Calling npmPeer will automatically add it to the enclosing dependency collector.

kotlin.sourceSets["jsMain"].dependencies {
npmPeer("is-odd-even", "1.1.0")
}

The version will be parsed by node-semver. See the node-semver README for the supported syntax.

Creating NPM dependencies is only relevant for Kotlin entities that target JS or WasmJS.

Parameters

name

The NPM dependency name

version

The NPM dependency version


abstract fun npmPeer(name: String, version: Provider<String>)

Declares a dependency on a NPM module that is added to peerDependencies.

NPM peer dependencies should not be applied to Gradle dependency scopes such as api, implementation, and so on. Calling npmPeer will automatically add it to the enclosing dependency collector.

version is resolved lazily, so it may be provided by a value that is not yet known when the declaration is made:

kotlin.sourceSets["jsMain"].dependencies {
npmPeer(
"is-odd-even",
project.providers.gradleProperty("isOddEvenVersion"),
)
}

If version has no value, then the build fails when the declaration is used.

The version will be parsed by node-semver. See the node-semver README for the supported syntax.

Creating NPM dependencies is only relevant for Kotlin entities that target JS or WasmJS.

Parameters

name

The NPM dependency name

version

The provider of the NPM dependency version