rmrk-tools
rmrk-tools copied to clipboard
publish dual packages (ESM + CommonJS)
is it possible to to publish dual packages (ESM + CommonJS), using conditional exports?
Is it possible to use rmrk-tools with node? When I try to use it with imports/exports module I get the following error:
$ node script.js
file:///Users/bruno/src/examples/node-dot/getRemarks.js:1
import { fetchRemarks, getRemarksFromBlocks, getLatestFinalizedBlock, Consolidator } from 'rmrk-tools';
^^^^^^^^^^^^
SyntaxError: Named export 'Consolidator' not found. The requested module 'rmrk-tools' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'rmrk-tools';
const { fetchRemarks, getRemarksFromBlocks, getLatestFinalizedBlock, Consolidator } = pkg;
yes. rmrk has yet to solve this issue. I just end up adding "type": "module" to the rmrk-tools package.json . It is a bit tedious to do it each time I update the dependency but that is my fix for now.
It would be nice if "type": "module" could be added to the package json.