/** * @since v0.3.7 */ declare module 'module' { import { URL } from 'node:url'; namespace Module { /** * 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`. * * ```js * const fs = require('node:fs'); * const assert = require('node:assert'); * const { syncBuiltinESMExports } = require('node:module'); * * fs.readFile = newAPI; * * delete fs.readFileSync; * * function newAPI() { * // ... * } * * fs.newAPI = newAPI; * * syncBuiltinESMExports(); * * import('node:fs').then((esmFS) => { * // It syncs the existing readFile property with the new value * assert.strictEqual(esmFS.readFile, newAPI); * // readFileSync has been deleted from the required fs * assert.strictEqual('readFileSync' in fs, false); * // syncBuiltinESMExports() does not remove readFileSync from esmFS * assert.strictEqual('readFileSync' in esmFS, true); * // syncBuiltinESMExports() does not add names * assert.strictEqual(esmFS.newAPI, undefined); * }); * ``` * @since v12.12.0 */ function syncBuiltinESMExports(): void; /** * `path` is the resolved path for the file for which a corresponding source map * should be fetched. * @since v13.7.0, v12.17.0 * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. */ function findSourceMap(path: string, error?: Error): SourceMap; interface SourceMapPayload { file: string; version: number; sources: string[]; sourcesContent: string[]; names: string[]; mappings: string; sourceRoot: string; } interface SourceMapping { generatedLine: number; generatedColumn: number; originalSource: string; originalLine: number; originalColumn: number; } /** * @since v13.7.0, v12.17.0 */ class SourceMap { /** * Getter for the payload used to construct the `SourceMap` instance. */ readonly payload: SourceMapPayload; constructor(payload: SourceMapPayload); /** * Given a line offset and column offset in the generated source * file, returns an object representing the SourceMap range in the * original file if found, or an empty object if not. * * The object returned contains the following keys: * * The returned value represents the raw range as it appears in the * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and * column numbers as they appear in Error messages and CallSite * objects. * * To get the corresponding 1-indexed line and column numbers from a * lineNumber and columnNumber as they are reported by Error stacks * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)` * @param lineOffset The zero-indexed line number offset in the generated source * @param columnOffset The zero-indexed column number offset in the generated source */ findEntry(lineOffset: number, columnOffset: number): SourceMapping; } } interface Module extends NodeModule {} class Module { static runMain(): void; static wrap(code: string): string; static createRequire(path: string | URL): NodeRequire; static builtinModules: string[]; static isBuiltin(moduleName: string): boolean; static Module: typeof Module; constructor(id: string, parent?: Module); } global { interface ImportMeta { url: string; /** * @experimental * This feature is only available with the `--experimental-import-meta-resolve` * command flag enabled. * * Provides a module-relative resolution function scoped to each module, returning * the URL string. * * @param specified The module specifier to resolve relative to `parent`. * @param parent The absolute parent module URL to resolve from. If none * is specified, the value of `import.meta.url` is used as the default. */ resolve?(specified: string, parent?: string | URL): Promise; } } export = Module; } declare module 'node:module' { import module = require('module'); export = module; }