You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The main field is a module ID that is the primary entry point to your program. That is, if your package is named foo, and a user installs it, and then does require("foo"), then your main module's exports object will be returned.
Since require operates on CJS modules, it makes no sense to declare an ESM main. Instead of "main": "esm/index.js", hashids should have "main": "cjs/index.js".
A consequence of this that we hit is that on older (but still LTS) versions of Node.js which do not have the exports mechanism, doing require("hashids") attempts to load hashids/esm/index.js, which fails due to that file being ESM, unsupported by Node.js. (We use TypeScript. The failure just mentioned occurs when we try to run our transpiled tests. We can’t directly load the module hashids/cjs either, since for our production build we use Rollup, the plugin-node-resolve of which was recently updated to respect exports, so it does not rollup subpaths not listed in exports)
The text was updated successfully, but these errors were encountered:
From the
npm
documentation:Since
require
operates on CJS modules, it makes no sense to declare an ESM main. Instead of"main": "esm/index.js"
,hashids
should have"main": "cjs/index.js"
.A consequence of this that we hit is that on older (but still LTS) versions of Node.js which do not have the
exports
mechanism, doingrequire("hashids")
attempts to loadhashids/esm/index.js
, which fails due to that file being ESM, unsupported by Node.js. (We use TypeScript. The failure just mentioned occurs when we try to run our transpiled tests. We can’t directly load the modulehashids/cjs
either, since for our production build we use Rollup, theplugin-node-resolve
of which was recently updated to respectexports
, so it does not rollup subpaths not listed inexports
)The text was updated successfully, but these errors were encountered: