feat!: update multiformats, publish as ESM - #4
achingbrain wants to merge 1 commit into
Conversation
Updates multiformats module to 10.x.x. This module is now published as ESM-only so I had to update `tsconfig.json` to do the same here otherwise this module gets transpiled to CJS which then explodes at runtime when trying to import the ESM-only multiformats. I removed ts-jest as I just couldn't get it to work with ESM-only modules, instead using babel's `@babel/preset-typescript` to compile ts to js. There were also two snapshots directories - `__snapshots__` and `__SNAPSHOTS__` in this repo which wreak havoc on case-insensitive filesystems like MacOS, hopefully there's only one directory now.
|
Hey @achingbrain , thanks for looking at this and greatly improving the quality of this repository. As a status update, I just pulled this PR to my local machine and ran it through the linter. As usual, at least for me, I get ESM and CJS complaints for code bases. I'll try to update here as I fiddle around a bit more to be confident what needs to be there. Sergey, over at Ceramic, recently helped me clean up nist-weierstrauss. I'll go over to that repo for inspiration, snyc with you, etc...and get this done.. |
|
hmm.. as a note to myself..it may be one in the same problem... how to express ESM may just be something I need I learn about. |
|
fwiw, here are a few links I am looking at in order to understand this problem: https://bobbyhadz.com/blog/javascript-error-err-require-esm-require-of-es-module-not-supported https://answers.netlify.com/t/error-err-require-esm-require-of-es-module/53937 https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/ |
|
I created a parallel branch [1] to test this out with some of the configuration that came from https://github.com/bshambaugh/nist-weierstrauss . [1] https://github.com/bshambaugh/did-key-creator/tree/scratch-main-pr4 I actually did reference did-key-creator from https://github.com/ceramicnetwork/js-did/blob/main/packages/key-did-resolver/README.md (because it provided a means to kick off the resolver) and it was used in the tests for so in short, @ukstv might be interested in helping address this problem. Good catch addressing the snapshots and SNAPSHOTS case sensitive problem in this repository. I'm unsure. Is this an urgent enough problem that I should try to get that out before this PR is even complete? |
|
Status update. I'm still fidgeting with CJS and ESM. Bear with me as the migration to ESM has been compared to Python 2 vs 3. https://www.claritician.com/typescript-lib-vs-target-what-s-the-difference (comparing target and lib properties in tsconfig) edit: another status update, general docs: https://www.typescriptlang.org/tsconfig. I'm learning. Hopefully I'm closer. |
|
Hey @achingbrain , I started from scratch and created a new version 1.2.0 for https://www.npmjs.com/package/did-key-creator . It seems to be usable for my purposes and it corrects for the duplicate snapshot and ESM issue. Feel free to try it and let me know if you have any issues. Also, let me know how I might credit you. |
Updates multiformats module to 10.x.x. This module is now published as ESM-only so I had to update
tsconfig.jsonto do the same here otherwise this module gets transpiled to CJS which then explodes at runtime when trying to import the ESM-only multiformats.I removed ts-jest as I just couldn't get it to work with ESM-only modules, instead using babel's
@babel/preset-typescriptto compile ts to js.There were also two snapshots directories -
__snapshots__and__SNAPSHOTS__in this repo which wreak havoc on case-insensitive filesystems like MacOS, hopefully there's only one directory now.