@apistudio/apim-cli
Version:
CLI for API Management Products
20 lines (19 loc) • 711 B
JavaScript
/**
* Lazy-loaded parent directory to avoid immediate execution of Node.js-specific imports.
* This prevents bundling issues in browser-based applications.
*/
let _parentDir = null;
/**
* Get the directory name of the current module.
* Lazy loads Node.js dependencies (url, path) only when needed.
*/
export async function getParentDir() {
if (_parentDir === null) {
// Lazy import to avoid bundling Node.js modules in browser apps
const { fileURLToPath } = await import('url');
const path = await import('path');
const currentFile = fileURLToPath(import.meta.url);
_parentDir = path.resolve(path.dirname(currentFile), '../src');
}
return _parentDir;
}