Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mifi/commonify
Recursively publish ESM packages as CommonJS!
https://github.com/mifi/commonify
cjs commonjs esm transpiler
Last synced: 12 days ago
JSON representation
Recursively publish ESM packages as CommonJS!
- Host: GitHub
- URL: https://github.com/mifi/commonify
- Owner: mifi
- License: mit
- Created: 2022-01-24T07:32:16.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-05T21:09:34.000Z (over 2 years ago)
- Last Synced: 2024-11-01T07:24:29.896Z (19 days ago)
- Topics: cjs, commonjs, esm, transpiler
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 32
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Commonify.js
For us who are still relying on CommonJS, or using Electron [which does not support ESM](https://github.com/electron/electron/issues/21457).
🆕 See also [build-electron](https://github.com/mifi/build-electron)
I made this tool that makes it easy to:
- Pull any ESM package from npm
- Transpile it from ESM to CommonJS using babel
- Publish it under a custom npm scope
- Recursively do the same for all dependencies**It is mostly an experiment**, and it feels like a step back in terms of the ecosystem moving to ESM, so if anyone has any other great ideas, please submit an issue! I have thought about the possibility of doing something similar to the `node_modules` folder in an npm `postinstall` script.
## Usage
First create your scope here: https://www.npmjs.com/org/create
```bash
git clone https://github.com/mifi/commonify.git
cd commonifyyarn
node cli.mjs lowdb 3.0.0 myscope
```
This will create the package `@myscope/lowdb` and its dependencies ready to publish to npm.## Example packages
I will publish commonified packages to the `@commonify` scope:
- `@commonify/lowdb`
- `@commonify/steno`
- `@commonify/execa`
- `@commonify/strip-final-newline`
- `@commonify/onetime`
- `@commonify/mimic-fn`
- `@commonify/npm-run-path`
- `@commonify/path-key`
- `@commonify/is-stream`## Todo
- **Support already scoped packages**
- Must support dual modules (they also have `"type": "module"` set). Example: https://github.com/yargs/yargs-parser/blob/main/package.json
- Automate when upstream package version updates
- Auto-generate a list of versions and their version corresponding to upstream version