1.0.2 • Published 3 years ago
cjs-globals v1.0.2
cjs-globals
This module mimics some CommonJS globals, such as __dirname and __filename,
in an ECMAScript module.
Installation
npm install cjs-globalsUsage
// File: example.mjs
import cjs from 'cjs-globals'
cjs.__filename // => /Users/JohnDoe/Documents/example.mjs
cjs.__dirname // => /Users/JohnDoe/DocumentsCaveats
This module is not a complete implementation of CommonJS globals. The require
function is not properly implemented, and is discouraged in favor of native
ECMAScript import syntax.
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.