getCommonJS
Function: getCommonJS()
getCommonJS(
urlInfo):object
Defined in: packages/utils/src/esm.ts:14
Get CommonJS-style __filename and __dirname equivalents for ESM modules.
Parameters
urlInfo
string
The import.meta.url of the calling module
Returns
object
An object containing __filename (absolute file path) and __dirname (directory path)
__dirname
__dirname:
string
__filename
__filename:
string
Example
const { __filename, __dirname } = getCommonJS(import.meta.url);