bare-module
Reference for bare-module: Bare's module system—CommonJS and ESM resolution, loading, and the require / import.meta surfaces.
bare-module implements Bare's module system: CommonJS and ESM with bidirectional interop, native-addon and asset resolution, and the require / import.meta surfaces. It's the machinery behind bare's Module.load(). It's a native addon and requires Bare >=1.23.0 <1.29.0.
npm i bare-moduleUsage
const Module = require('bare-module')API
Module
const url = Module.resolve(specifier, parentURL[, options]) · Module.asset(specifier, parentURL[, options])
Resolve a module or asset specifier to a URL.
const module = Module.load(url[, source][, options])
Load (and cache) a module. The returned module exposes url, filename, dirname, type, defaultType, cache, main, exports, imports, resolutions, builtins, conditions, and protocol.
Module.constants · Module.protocol · Module.cache
Module state/type constants, the protocol table, and the global module cache.
require
require(specifier[, options]) plus require.main, require.cache, require.resolve(specifier[, parentURL]), require.addon([specifier][, parentURL]) (with require.addon.host and require.addon.resolve(...)), and require.asset(specifier[, parentURL]).
import / import.meta
Static and dynamic import (including import attributes, e.g. with { type: 'json' }), plus import.meta.url, import.meta.main, import.meta.cache, import.meta.dirname, import.meta.filename, import.meta.resolve(specifier[, parentURL]), and import.meta.addon([specifier][, parentURL]).
Related modules
Builds on bare-module-resolve, bare-module-lexer, bare-bundle, bare-path, and bare-url.
See also
bare-module-resolveandbare-module-traverse—the resolution and traversal algorithms underneath.- Bare runtime API—
Bare.Addon, the native-addon loaderrequire.addonbuilds on. - Bare modules—the full
bare-*catalog.