0.0.3 • Published 3 years ago

import-commonjs v0.0.3

Weekly downloads
439
License
MIT
Repository
github
Last release
3 years ago

import-commonjs

Build Status Coverage Npm Version MIT License

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

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

4 years ago

0.0.0

4 years ago