import-commonjs

0.0.3 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i import-commonjs

Weekly Downloads

3

Version

0.0.3

License

MIT

Unpacked Size

5.29 kB

Total Files

4

Last publish

Collaborators

  • fisker