Package-level declarations

Types

Link copied to clipboard
sealed external interface GlobalPreloadContext
Link copied to clipboard
Link copied to clipboard
sealed external interface ImportAttributes : Record<String, String>
Link copied to clipboard
typealias InitializeHook<Data> = (data: Data) -> PromiseResult<Void>

The initialize hook provides a way to define a custom function that runs in the hooks thread when the hooks module is initialized. Initialization happens when the hooks module is registered via register.

Link copied to clipboard
sealed external interface LoadFnOutput
Link copied to clipboard
typealias LoadHook = (url: String, context: LoadHookContext, nextLoad: (url: String, context: LoadHookContext?) -> PromiseResult<LoadFnOutput>) -> PromiseResult<LoadFnOutput>

The load hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed. It is also in charge of validating the import assertion.

Link copied to clipboard
sealed external interface LoadHookContext
Link copied to clipboard
external class Module : Module
Link copied to clipboard
sealed external interface ModuleFormat
Link copied to clipboard
typealias ModuleSource = Any
Link copied to clipboard
sealed external interface RegisterOptions<Data>
Link copied to clipboard
sealed external interface ResolveFnOutput
Link copied to clipboard
typealias ResolveHook = (specifier: String, context: ResolveHookContext, nextResolve: (specifier: String, context: ResolveHookContext?) -> PromiseResult<ResolveFnOutput>) -> PromiseResult<ResolveFnOutput>

The resolve hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as 'module') as a hint to the load hook. If a format is specified, the load hook is ultimately responsible for providing the final format value (and it is free to ignore the hint provided by resolve); if resolve provides a format, a custom load hook is required even if only to pass the value to the Node.js default load hook.

Link copied to clipboard
sealed external interface ResolveHookContext
Link copied to clipboard
external class SourceMap
Link copied to clipboard
sealed external interface SourceMapPayload
Link copied to clipboard
sealed external interface SourceMapping
Link copied to clipboard
sealed external interface SourceOrigin

Functions

Link copied to clipboard
external fun findSourceMap(path: String, error: JsError = definedExternally): SourceMap

path is the resolved path for the file for which a corresponding source map should be fetched.

Link copied to clipboard
external fun syncBuiltinESMExports()

The module.syncBuiltinESMExports() method updates all the live bindings for builtin ES Modules to match the properties of the CommonJS exports. It does not add or remove exported names from the ES Modules.