import-sync
Version:
Synchronously import dynamic ECMAScript Modules similar to CommonJS require. Basic wrapper around esm for compatibility with both ESM and CJS projects in NodeJS.
19 lines (18 loc) • 598 B
TypeScript
/**
* Get the file path of the caller function.
*
* Implementation inspired by:
* - https://www.npmjs.com/package/callsite?activeTab=code
*
* @returns {string} absolute path or an empty string if no caller
*/
export declare const getCallerDirname: () => string;
/**
* Find the module file path
*
* @param {string} modulePath - The path to the module
* @param {string} basePath - The base path for the module
* @returns {string} The resolved file path
* @throws {Error} If the file is not found
*/
export declare const findModuleFile: (basePath: string, modulePath: string) => string;