kevlened / isomorphic-webcrypto

:game_die: webcrypto library for Node, React Native and IE11+
https://www.w3.org/TR/WebCryptoAPI/
MIT License
116 stars 42 forks source link

`WebCrypto` is a namespace import in index.mjs; `WebCrypto.Crypto` is the constructor to be instantiated #29

Closed CxRes closed 4 years ago

CxRes commented 4 years ago

This is a regression introduced by #28. In line with index.js, the code in index.mjs needs to be changed to:

import * as webcrypto from '@peculiar/webcrypto'
export default new webcrypto.Crypto()
florent-andre commented 4 years ago

I'm also hiting this regressions. Whereas, with your solution @CxRes, in my configuration (Gatsbyjs with Babel and a lot of other stuffs) I get :

Can't import the named export 'Crypto' from non EcmaScript module (only default export is available)

With no clues from where it comes.

CxRes commented 4 years ago

@florent-andre I am hitting the same bug too - with Webpack (but not with Rollup)! Note that in this case for some reason your bundler/runner is looking to load the cjs version (and not esm version) of @peculiar/webcrypto.

At least with Webpack, if I load @peculiar/webcrypto directly from my main, it loads the esm version but if I load isomorphic-webcrypto then it attempts to load the cjs version. Very annoying!

kevlened commented 4 years ago

Thanks for the heads up. I'll publish a new version shortly.

kevlened commented 4 years ago

Fixed in 2.3.6. Thanks again