paulmillr/micro-eth-signer

Using with node + tsc

stereosteve opened this issue · 3 comments

Using in nodejs with typescript (either tsc or ts-node) I get:

Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/micro-eth-signer/index.js from /app/build/src/server.js not supported.

But other libraries of yours like @scure/base work fine, so seems like some aspect of the packaging config is different. Would it be possible to package this lib like the rest so it Just Works in node + typescript?

Thanks for all the great libs btw!

micro eth signer is esm-only. I want to eventually move scure and others to it as well. It's better and getting more popular.

So, I suggest to upgrade your typescript config for esm support.

Note that esm packages could import old require() common.js packages. But common.js packages can't import esm.

Okay, I ended up adding "type": "module" and using node --experimental-modules --es-module-specifier-resolution=node and got it working.

Yeah I look forward to a future where ES Modules just work everywhere!

As a side note, experimental-modules is not probably needed in nodejs 16 or later