import-commonjs
v0.0.3
Published
Import CommonJS modules in the safe way
Downloads
41
Readme
import-commonjs
Import ECMAScript modules in the safe way
Install
yarn add import-commonjs
# or
npm install import-commonjs
Usage
import importCommonjs from 'import-commonjs'
const require = importCommonjs(import.meta.url)
console.log(require('./foo.cjs'))
//=> { name: 'foo' }
API
importCommonjs(url)
Filename to be used to construct the require function. Must be a file URL object, file URL string, or absolute path string.
Returns require
function.
url
Type: string
Related
import-esm
import.mjs
file.