LogoPear Docs
ReferencesBareModules

bare-addon-resolve

Reference for bare-addon-resolve: the low-level native-addon resolution algorithm for Bare, exposed as a generator.

bare-addon-resolve implements Bare's low-level resolution algorithm for native addons—the counterpart to bare-module-resolve for .bare / prebuilt binaries. It's a pure-JavaScript generator that yields candidate addon URLs for a specifier.

A low-level building block. Addons normally resolve through the runtime or are bundled by bare-pack; use this directly only in tooling.

npm i bare-addon-resolve

Usage

const resolve = require('bare-addon-resolve')

function readPackage (url) {
  // Read and parse `url` if it exists, otherwise return null
}

for (const resolution of resolve('./addon', new URL('file:///directory/'), readPackage)) {
  console.log(resolution)
}

An asynchronous form is supported by iterating with for await.

API

const resolver = resolve(specifier, parentURL[, options][, readPackage])

Create an addon resolver. Iterate synchronously or with for await; each yielded value is a candidate addon URL.

Sub-generators

resolve.addon, resolve.url, resolve.package, resolve.packageSelf, resolve.preresolved, resolve.file, resolve.directory, and resolve.linked expose the algorithm's steps—including linked, which resolves to linked: specifiers for runtimes that link addons ahead of time (iOS and Android). See the repository README.

Builds on bare-module-resolve and bare-semver (see Bare modules).

See also

On this page