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.
npm i bare-addon-resolveUsage
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.
Related modules
Builds on bare-module-resolve and bare-semver (see Bare modules).
See also
bare-module-traverse—uses this to find a graph's addons.- Bare runtime API—
Bare.Addon, the runtime addon loader. - Bare modules—the full
bare-*catalog.