Open toteto opened 11 months ago
Sorry, for not responding earlier. Totally overlooked the issues in this repo and we had no issues in RN because of babel.
Implemented a workaround, as we cannot move to ESM only yet. We will move to both CJS and ESM soon though, so then we can properly fix it. Will keep this ticket open
I have a project that is declared as ESM module (it has
"type":"module"
) inpackage.json
. When I import and try to use@sphereon/ssi-sdk-ext.did-resolver-key
I get the error:This is because the version of
nist-weierstrauss
that is used (v1.6.1), has only ESM builds available. This should be OK, butssi-sdk-ext.did-resolver-key
is distributing only CJS and the import it is making for thenist-weierstrauss
uses therequire
statement. Importing ESM modules withrequire
is not allowed.Minimum reproduction
https://stackblitz.com/edit/stackblitz-starters-6hjrdu
Workaround
As a workaround for my case I have downgraded the nist-weierstrauss to v1.4.1, it is their last delivery as CJS library. For now seems ok.
An alternative workaround, if you have TS setup, is to patch the
ssi-sdk-ext.did-resolver-key
delivery that will list"main":"src/index.ts"
in thepackage.json
. This will take the TS source code directly and transpile it to ESM.Solution
tsc
to output ESM instead of CJS (or run it two times to output both)tsup
oresbuild
orrollup
to create delivery for both CJS and ESM