Function getEsmPath

  • Creates the equivalent of CJS's __dirname and __filename for ESM modules.

    This is the equivalent of import.meta.dirname and import.meta.filename added to Node.js v20.11.0 but is compatible with older versions of Node.js as well as browsers.

    Parameters

    • importMeta: ImportMeta

    Returns {
        dirPath: string;
        filePath: string;
    }

    • dirPath: string
    • filePath: string
    import {getEsmPath} from '@augment-vir/common';

    const {filePath, dirPath} = getEsmPath(import.meta);

    @augment-vir/common