Skip to content

Instantly share code, notes, and snippets.

View JoviDeCroock's full-sized avatar
🐨

Jovi De Croock JoviDeCroock

🐨
View GitHub Profile
const { appendFile } = require("fs");
const fetch = require("node-fetch");
const fs = require('fs');
const params = JSON.parse(fs.readFileSync('./config.json'));
/* Example
{
"accountManager": {
"scope": "SALESFORCE_COMMERCE_API:xxxx_xxx sfcc.yy",
"clientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
@JoviDeCroock
JoviDeCroock / *cjyes.md
Created May 20, 2020 18:50 — forked from developit/*cjyes.md
more-or-less instant command-line ESM to CJS transform. Copies from src to dist. `cjyes src/*.js`

cjyes npm version

🔍 see jay, yes! 🎉 / 👨🏻‍💻 see, JS! 👾 / ⚓️ sea JS ⛴

If you're publishing ES Modules, you need to also publish CommonJS versions of those modules.

This isn't to support old browsers or Node versions: even in Node 14, using require() to load a module won't work if it's only available as ESM.

cjyes is the bare minimum fix for this problem. You write ES Modules and fill out a valid package.json, and it'll generate the corresponding CommonJS files pretty much instantly. cjyes takes up 500kb of disk space including its two dependencies.