https://github.com/alexxnb/cjs2es
Converts source of any CommonJS module to the ES module
https://github.com/alexxnb/cjs2es
Last synced: 3 months ago
JSON representation
Converts source of any CommonJS module to the ES module
- Host: GitHub
- URL: https://github.com/alexxnb/cjs2es
- Owner: AlexxNB
- License: mit
- Created: 2020-03-05T11:36:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-20T01:38:57.000Z (almost 3 years ago)
- Last Synced: 2025-02-24T05:45:49.642Z (3 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cjs2es
Converts source of any CommonJS module to the ES module# Usage
```javascript
import {cjs2es} from 'cjs2es';const cjsSource = `
const modulename = require('some-module');
console.log(modulename);
module.exports = {foo: 'bar'}
`;const esSource = cjs2es(cjsSource);
```# Copyright
Original idea is from here:
https://github.com/sveltejs/svelte-repl/blob/master/src/workers/bundler/plugins/commonjs.js