Repository: char0n/ramda-adjunct
Pull request #2947 (2024-04-08 06:33:55)

feat: convert to hybrid npm package (ESM & CommonJS)
This conversion has been done in fully backward
compatible way.

Refs #2916



Patch:
diff --git a/.mocharc.js b/.mocharc.cjs
similarity index 93%
rename from .mocharc.js
rename to .mocharc.cjs
index bb2bd876dc..6e1561e2cc 100644
--- a/.mocharc.js
+++ b/.mocharc.cjs
@@ -1,4 +1,4 @@
-'use strict';
+"use strict";
 
 module.exports = {
   recursive: true,
diff --git a/babel.config.js b/babel.config.cjs
similarity index 100%
rename from babel.config.js
rename to babel.config.cjs
diff --git a/package-lock.json b/package-lock.json
index f56f04e7c8..b63297d76c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -23,7 +23,7 @@
         "babel-plugin-annotate-pure-calls": "0.4.0",
         "babel-plugin-istanbul": "6.1.1",
         "better-npm-run": "0.1.1",
-        "chai": "4.4.1",
+        "chai": "5.1.0",
         "codecov": "3.8.3",
         "conventional-changelog-cli": "4.1.0",
         "core-js": "=3.35.1",
@@ -4308,12 +4308,12 @@
       }
     },
     "node_modules/assertion-error": {
-      "version": "1.1.0",
-      "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
-      "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
+      "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
       "dev": true,
       "engines": {
-        "node": "*"
+        "node": ">=12"
       }
     },
     "node_modules/async": {
@@ -4858,21 +4858,19 @@
       }
     },
     "node_modules/chai": {
-      "version": "4.4.1",
-      "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz",
-      "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==",
+      "version": "5.1.0",
+      "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.0.tgz",
+      "integrity": "sha512-kDZ7MZyM6Q1DhR9jy7dalKohXQ2yrlXkk59CR52aRKxJrobmlBNqnFQxX9xOX8w+4mz8SYlKJa/7D7ddltFXCw==",
       "dev": true,
       "dependencies": {
-        "assertion-error": "^1.1.0",
-        "check-error": "^1.0.3",
-        "deep-eql": "^4.1.3",
-        "get-func-name": "^2.0.2",
-        "loupe": "^2.3.6",
-        "pathval": "^1.1.1",
-        "type-detect": "^4.0.8"
+        "assertion-error": "^2.0.1",
+        "check-error": "^2.0.0",
+        "deep-eql": "^5.0.1",
+        "loupe": "^3.1.0",
+        "pathval": "^2.0.0"
       },
       "engines": {
-        "node": ">=4"
+        "node": ">=12"
       }
     },
     "node_modules/chalk": {
@@ -4908,15 +4906,12 @@
       }
     },
     "node_modules/check-error": {
-      "version": "1.0.3",
-      "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz",
-      "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==",
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.0.0.tgz",
+      "integrity": "sha512-tjLAOBHKVxtPoHe/SA7kNOMvhCRdCJ3vETdeY0RuAc9popf+hyaSV6ZEg9hr4cpWF7jmo/JSWEnLDrnijS9Tog==",
       "dev": true,
-      "dependencies": {
-        "get-func-name": "^2.0.2"
-      },
       "engines": {
-        "node": "*"
+        "node": ">= 16"
       }
     },
     "node_modules/chokidar": {
@@ -5955,13 +5950,10 @@
       }
     },
     "node_modules/deep-eql": {
-      "version": "4.1.3",
-      "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
-      "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==",
+      "version": "5.0.1",
+      "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.1.tgz",
+      "integrity": "sha512-nwQCf6ne2gez3o1MxWifqkciwt0zhl0LO1/UwVu4uMBuPmflWM4oQ70XMqHqnBJA+nhzncaqL9HVL6KkHJ28lw==",
       "dev": true,
-      "dependencies": {
-        "type-detect": "^4.0.0"
-      },
       "engines": {
         "node": ">=6"
       }
@@ -10277,9 +10269,9 @@
       }
     },
     "node_modules/loupe": {
-      "version": "2.3.7",
-      "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz",
-      "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==",
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.0.tgz",
+      "integrity": "sha512-qKl+FrLXUhFuHUoDJG7f8P8gEMHq9NFS0c6ghXG1J0rldmZFQZoNVv/vyirE9qwCIhWZDsvEFd1sbFu3GvRQFg==",
       "dev": true,
       "dependencies": {
         "get-func-name": "^2.0.1"
@@ -11893,12 +11885,12 @@
       }
     },
     "node_modules/pathval": {
-      "version": "1.1.1",
-      "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
-      "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz",
+      "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==",
       "dev": true,
       "engines": {
-        "node": "*"
+        "node": ">= 14.16"
       }
     },
     "node_modules/picocolors": {
@@ -18529,9 +18521,9 @@
       }
     },
     "assertion-error": {
-      "version": "1.1.0",
-      "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
-      "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
+      "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
       "dev": true
     },
     "async": {
@@ -18916,18 +18908,16 @@
       }
     },
     "chai": {
-      "version": "4.4.1",
-      "resolved": "https://registry.npmjs.org/chai/-/chai-4.4.1.tgz",
-      "integrity": "sha512-13sOfMv2+DWduEU+/xbun3LScLoqN17nBeTLUsmDfKdoiC1fr0n9PU4guu4AhRcOVFk/sW8LyZWHuhWtQZiF+g==",
+      "version": "5.1.0",
+      "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.0.tgz",
+      "integrity": "sha512-kDZ7MZyM6Q1DhR9jy7dalKohXQ2yrlXkk59CR52aRKxJrobmlBNqnFQxX9xOX8w+4mz8SYlKJa/7D7ddltFXCw==",
       "dev": true,
       "requires": {
-        "assertion-error": "^1.1.0",
-        "check-error": "^1.0.3",
-        "deep-eql": "^4.1.3",
-        "get-func-name": "^2.0.2",
-        "loupe": "^2.3.6",
-        "pathval": "^1.1.1",
-        "type-detect": "^4.0.8"
+        "assertion-error": "^2.0.1",
+        "check-error": "^2.0.0",
+        "deep-eql": "^5.0.1",
+        "loupe": "^3.1.0",
+        "pathval": "^2.0.0"
       }
     },
     "chalk": {
@@ -18957,13 +18947,10 @@
       }
     },
     "check-error": {
-      "version": "1.0.3",
-      "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.3.tgz",
-      "integrity": "sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==",
-      "dev": true,
-      "requires": {
-        "get-func-name": "^2.0.2"
-      }
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.0.0.tgz",
+      "integrity": "sha512-tjLAOBHKVxtPoHe/SA7kNOMvhCRdCJ3vETdeY0RuAc9popf+hyaSV6ZEg9hr4cpWF7jmo/JSWEnLDrnijS9Tog==",
+      "dev": true
     },
     "chokidar": {
       "version": "3.5.3",
@@ -19718,13 +19705,10 @@
       }
     },
     "deep-eql": {
-      "version": "4.1.3",
-      "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
-      "integrity": "sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==",
-      "dev": true,
-      "requires": {
-        "type-detect": "^4.0.0"
-      }
+      "version": "5.0.1",
+      "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.1.tgz",
+      "integrity": "sha512-nwQCf6ne2gez3o1MxWifqkciwt0zhl0LO1/UwVu4uMBuPmflWM4oQ70XMqHqnBJA+nhzncaqL9HVL6KkHJ28lw==",
+      "dev": true
     },
     "deep-is": {
       "version": "0.1.4",
@@ -22875,9 +22859,9 @@
       }
     },
     "loupe": {
-      "version": "2.3.7",
-      "resolved": "https://registry.npmjs.org/loupe/-/loupe-2.3.7.tgz",
-      "integrity": "sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==",
+      "version": "3.1.0",
+      "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.0.tgz",
+      "integrity": "sha512-qKl+FrLXUhFuHUoDJG7f8P8gEMHq9NFS0c6ghXG1J0rldmZFQZoNVv/vyirE9qwCIhWZDsvEFd1sbFu3GvRQFg==",
       "dev": true,
       "requires": {
         "get-func-name": "^2.0.1"
@@ -24093,9 +24077,9 @@
       "dev": true
     },
     "pathval": {
-      "version": "1.1.1",
-      "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz",
-      "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==",
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz",
+      "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==",
       "dev": true
     },
     "picocolors": {
diff --git a/package.json b/package.json
index 9542d7f421..056fe2b4ba 100644
--- a/package.json
+++ b/package.json
@@ -58,19 +58,29 @@
     }
   ],
   "sideEffects": false,
+  "type": "module",
   "main": "./lib/index.js",
   "module": "./es/index.js",
   "jsnext:main": "./es/index.js",
   "types": "types/index.d.ts",
+  "exports": {
+    ".": {
+      "import": "./es/index.js",
+      "require": "./lib/index.js",
+      "types": "./types/index.d.ts"
+    },
+    "./es/*": "./es/*.js",
+    "./lib/*": "./lib/*.js"
+  },
   "scripts": {
     "docs": "better-npm-run docs",
     "lint": "better-npm-run lint",
     "lint:fix": "better-npm-run lint:fix",
     "changelog": "better-npm-run changelog",
-    "test": "better-npm-run test",
+    "test": "mocha",
     "test:web": "better-npm-run test:web",
     "test:ramda": "bnr test:ramda",
-    "test:types": "eslint --no-eslintrc --no-ignore -c ./types/dtslint.eslint.js ./types/test/*.ts",
+    "test:types": "eslint --no-eslintrc --no-ignore -c ./types/dtslint.eslint.cjs ./types/test/*.ts",
     "test:bundle-create": "better-npm-run test:bundle-create",
     "test:bundle-clean": "better-npm-run test:bundle-clean",
     "coverage": "better-npm-run coverage",
@@ -83,19 +93,13 @@
   },
   "betterScripts": {
     "docs": "jsdoc -c jsdoc.json && node ./scripts/jsdoc-inject-dist.js",
-    "lint": "eslint ./ && eslint --no-ignore --no-eslintrc -c ./types/.eslintrc.js ./types/test/**/*.ts",
-    "lint:fix": "eslint --fix ./ && eslint --no-ignore --no-eslintrc --fix -c ./types/.eslintrc.js ./types/test/**/*.ts",
+    "lint": "eslint ./ && eslint --no-ignore --no-eslintrc -c ./types/.eslintrc.cjs ./types/test/**/*.ts",
+    "lint:fix": "eslint --fix ./ && eslint --no-ignore --no-eslintrc --fix -c ./types/.eslintrc.cjs ./types/test/**/*.ts",
     "changelog": "conventional-changelog -p angular -i ./CHANGELOG.md -s",
-    "test": {
-      "command": "mocha",
-      "env": {
-        "BABEL_ENV": "commonjs"
-      }
-    },
     "test:web": "testem ci",
     "test:ramda": "bnr test:ramda0.29.0",
     "test:ramda0.29.0": "npm install ramda@0.29.0 && npm test",
-    "test:bundle-create": "webpack --config webpack.config-test.web.js --progress",
+    "test:bundle-create": "webpack --config webpack.config-test.web.cjs --progress",
     "test:bundle-clean": "rimraf tmp-test-bundle.js",
     "coverage": {
       "command": "nyc mocha",
@@ -111,12 +115,12 @@
       }
     },
     "build:commonjs": {
-      "command": "babel src --out-dir lib",
+      "command": "babel src --out-dir lib && echo '{\"type\": \"commonjs\"}' > ./lib/package.json",
       "env": {
         "BABEL_ENV": "commonjs"
       }
     },
-    "build:umd": "webpack --config webpack.config.js --progress",
+    "build:umd": "webpack --config webpack.config.cjs --progress",
     "prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build && npm run docs",
     "clean": "rimraf .nyc_output .tmp docs coverage tmp-test-bundle.js dist lib es"
   },
@@ -138,7 +142,7 @@
     "babel-plugin-annotate-pure-calls": "0.4.0",
     "babel-plugin-istanbul": "6.1.1",
     "better-npm-run": "0.1.1",
-    "chai": "4.4.1",
+    "chai": "5.1.0",
     "codecov": "3.8.3",
     "core-js": "=3.35.1",
     "conventional-changelog-cli": "4.1.0",


Test patch:
diff --git a/test/cata.js b/test/cata.js
index c098289d58..fad05d8e2d 100644
--- a/test/cata.js
+++ b/test/cata.js
@@ -1,6 +1,6 @@
 import monet from 'monet';
 import folktale from 'folktale';
-import ramdaFantasy from 'ramda-fantasy/dist/ramda-fantasy';
+import ramdaFantasy from 'ramda-fantasy/dist/ramda-fantasy.js';
 import * as R from 'ramda';
 import { assert } from 'chai';
 
diff --git a/test/concatAll.js b/test/concatAll.js
index fbf118304f..197648bbdb 100644
--- a/test/concatAll.js
+++ b/test/concatAll.js
@@ -1,5 +1,5 @@
 import { assert } from 'chai';
-import { NEL, Nil } from 'monet';
+import monet from 'monet';
 import * as R from 'ramda';
 
 import * as RA from '../src/index.js';
@@ -14,7 +14,10 @@ describe('concatAll', function () {
   });
 
   it('should concatenate semigroups', function () {
-    assert.deepEqual(RA.concatAll([NEL(1), NEL(2)]), NEL(1, NEL(2, Nil)));
+    assert.deepEqual(
+      RA.concatAll([monet.NEL(1), monet.NEL(2)]),
+      monet.NEL(1, monet.NEL(2, monet.Nil))
+    );
   });
 
   context('given foldable is empty', function () {
diff --git a/test/lensTraverse.js b/test/lensTraverse.js
index 2fe96e625e..372f50e088 100644
--- a/test/lensTraverse.js
+++ b/test/lensTraverse.js
@@ -1,9 +1,11 @@
 import * as R from 'ramda';
 import { assert } from 'chai';
-import { Maybe } from 'monet';
+import monet from 'monet';
 
 import * as RA from '../src/index.js';
 
+const { Maybe } = monet;
+
 describe('lensTraverse', function () {
   it('should operate on a list of Applicatives', function () {
     const result = R.over(RA.lensTraverse(RA.Identity), R.map(R.add(1)), [
diff --git a/test/liftF.js b/test/liftF.js
index 385addf23c..da36ee80cd 100644
--- a/test/liftF.js
+++ b/test/liftF.js
@@ -1,9 +1,11 @@
 import { assert } from 'chai';
-import { Maybe } from 'monet';
+import monet from 'monet';
 import * as R from 'ramda';
 
 import * as RA from '../src/index.js';
 
+const { Maybe } = monet;
+
 const add3 = (a, b, c) => a + b + c;
 const add4 = (a, b, c, d) => a + b + c + d;
 const add5 = (a, b, c, d, e) => a + b + c + d + e;
diff --git a/test/liftFN.js b/test/liftFN.js
index 0a7219cef3..be3486f4fa 100644
--- a/test/liftFN.js
+++ b/test/liftFN.js
@@ -1,10 +1,12 @@
 import * as R from 'ramda';
 import { assert } from 'chai';
-import { Maybe } from 'monet';
+import monet from 'monet';
 
 import * as RA from '../src/index.js';
 import Identity from '../src/fantasy-land/Identity.js';
 
+const { Maybe } = monet;
+
 const addN = (...args) => R.sum(args);
 const add3 = (a, b, c) => a + b + c;
 
diff --git a/test/mocha-bootstrap.js b/test/mocha-bootstrap.js
index ec30047b01..e69de29bb2 100644
--- a/test/mocha-bootstrap.js
+++ b/test/mocha-bootstrap.js
@@ -1,3 +0,0 @@
-'use strict';
-
-require('@babel/register')({});
diff --git a/test/neither.js b/test/neither.js
index 5cccc61363..491e7ccd7c 100644
--- a/test/neither.js
+++ b/test/neither.js
@@ -1,10 +1,12 @@
 import { assert } from 'chai';
 import * as R from 'ramda';
-import { Just, Nothing } from 'monet';
+import monet from 'monet';
 import sinon from 'sinon';
 
 import * as RA from '../src/index.js';
 
+const { Just, Nothing } = monet;
+
 const supportsFantasyLand = () => {
   try {
     return RA.neither(Just(false), Just(true)).equals(Just(false));
diff --git a/test/notBoth.js b/test/notBoth.js
index 298db93064..0ea93648f5 100644
--- a/test/notBoth.js
+++ b/test/notBoth.js
@@ -1,10 +1,12 @@
 import { assert } from 'chai';
 import * as R from 'ramda';
-import { Just, Nothing } from 'monet';
+import monet from 'monet';
 import sinon from 'sinon';
 
 import * as RA from '../src/index.js';
 
+const { Just, Nothing } = monet;
+
 describe('notBoth', function () {
   it('should combine two boolean-returning functions into one', function () {
     const even = (x) => x % 2 === 0;
diff --git a/test/weave.js b/test/weave.js
index 53b338b177..f85ffac8a4 100644
--- a/test/weave.js
+++ b/test/weave.js
@@ -1,9 +1,11 @@
 import { assert } from 'chai';
 import { sum, curry } from 'ramda';
-import { Reader as reader } from 'monet';
+import monet from 'monet';
 
 import * as RA from '../src/index.js';
 
+const { Reader: reader } = monet;
+
 describe('weave', function () {
   const unaryReader = (a) => reader((config) => config + a);
   const binaryReader = (a, b) => reader((config) => config + a + b);
diff --git a/test/weaveLazy.js b/test/weaveLazy.js
index daec42d9c5..bfd94a6e22 100644
--- a/test/weaveLazy.js
+++ b/test/weaveLazy.js
@@ -1,9 +1,11 @@
 import { assert } from 'chai';
 import { sum, curry, always } from 'ramda';
-import { Reader as reader } from 'monet';
+import monet from 'monet';
 
 import * as RA from '../src/index.js';
 
+const { Reader: reader } = monet;
+
 describe('weaveLazy', function () {
   const unaryReader = (a) => reader((config) => config + a);
   const binaryReader = (a, b) => reader((config) => config + a + b);