Closed RobertoSnap closed 2 years ago
haha, I published a version here: https://www.npmjs.com/package/@symfoni/ethr-did-resolver. Types working, but its not "native" ESM. I have to dynamically import the module.
Same with ethr-did-resolver@7.0.0-alpha.1
Message im getting:
The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("ethr-did-resolver")' call instead. To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with
{ "type": "module" }.ts(1479)
From what I can figure, you're seeing that error because you're trying to import esm into a commonjs file.
I think this should be expected if ethr-did-resolver were pure-esm.
The problem is that it should actually be a commonjs build that also exposes an esm wrapper, so the bug is that ethr-did-resolver doesn't build as commonjs.
Do you have a project showing this error?
@RobertoSnap can you try to use ethr-did-resolver@7.0.0-alpha.2
?
It should present 2 entry points now: the library built as a commonjs
module and a wrapper for esm
.
In alpha.1, both artifacts were in fact esm
From what I can figure, you're seeing that error because you're trying to import esm into a commonjs file.
I think this should be expected if ethr-did-resolver were pure-esm.
The problem is that it should actually be a commonjs build that also exposes an esm wrapper, so the bug is that ethr-did-resolver doesn't build as commonjs.
Do you have a project showing this error?
Yea, soon. Testing pure ESM but switching to commonjs too see effect of changes so maybe got it while i had switched 😬
@RobertoSnap can you try to use
ethr-did-resolver@7.0.0-alpha.2
?It should present 2 entry points now: the library built as a
commonjs
module and a wrapper foresm
.In alpha.1, both artifacts were in fact esm
Will give it a try 👍
And what did you do to resolve the .json import in:
import { default as EthereumDIDRegistry } from './config/EthereumDIDRegistry.json';
@RobertoSnap can you try to use
ethr-did-resolver@7.0.0-alpha.2
?It should present 2 entry points now: the library built as a
commonjs
module and a wrapper foresm
.In alpha.1, both artifacts were in fact esm
Yea, getting error with
Cannot find module './config/EthereumDIDRegistry.json'. Consider using '--resolveJsonModule' to import module with '.json' extension.
From what i read about ESM, it cannot resolve .json 🤷♂️ https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
Hemm, nevermind. I reset config and it works now on ethr-did-resolver@7.0.0-alpha.2
Closed as @mirceanis allready working on a version of ethr-did-resolver@7.0.0-alpha.2
Will open issue with other ESM stuff
I was actually just working on this :)
Are you able to test it from
ethr-did-resolver@7.0.0-alpha.1
?