UNPKG

common-es

Version:

provides utilities for nodejs to be able to resolve es modules, such as providing the __dirname and __filename variables

8 lines (7 loc) 237 B
import { dirname } from 'path'; import { fileURLToPath } from 'url'; export default function getGlobals(url) { const __filename = fileURLToPath(url); const __dirname = dirname(__filename); return { __filename, __dirname }; }