1.0.2 • Published 1 year 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-globals
Usage
// File: example.mjs
import cjs from 'cjs-globals'
cjs.__filename // => /Users/JohnDoe/Documents/example.mjs
cjs.__dirname // => /Users/JohnDoe/Documents
Caveats
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.