1.1.0 • Published 4 years ago

commonjs-variables-for-esmodules v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

commonjs-variables-for-esmodules

Simple function for extract node variables dirname, filename, require and module from import.meta

Install

npm install --save commonjs-variables-for-esmodules
# or
yarn add commonjs-variables-for-esmodules

Limitations

  • node 12.2 or higher
  • use only in native ES modules

Usage

import commonjsVariables from 'commonjs-variables-for-esmodules';

const {
    __filename,
    __dirname,
    require,
    module
} = commonjsVariables(import.meta);

License

MIT