Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempted import error: 'DIDDataStore' is not exported from '@glazed/did-datastore' #39

Closed
META-DREAMER opened this issue Oct 7, 2021 · 3 comments

Comments

@META-DREAMER
Copy link

Getting this error when trying to use @self.id/core:

./node_modules/@self.id/core/dist/lib.mjs
Attempted import error: 'DIDDataStore' is not exported from '@glazed/did-datastore' (imported as 'D').

Running with create-react-app + typescript, node 14.7

@PaulLeCam
Copy link
Collaborator

It's likely an issue with Create React App, it's using an outdated version of Webpack. You should use Webpack 5 or an alternative modern bundler.

@jemgold
Copy link

jemgold commented Jan 9, 2022

I seem to be getting a similarish error with Next.js when I import usePublicRecord from @self.id/framework

I installed @3id/connect@^0.2.5 separately and confirmed that EthereumAuthProvider does exist - just looks like for some reason it's not being found by @self.id/web (see call stack at the end)

Any ideas?

Server Error
SyntaxError: Named export 'EthereumAuthProvider' not found. The requested module '@3id/connect' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@3id/connect';
const {ThreeIdConnect: l}from"@3id/connect";import{EthereumAuthProvider: k}from"@3id/connect";import{Core: v}from"@self.id/core";import{DID: f}from"dids";var s=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},d=(t,e,r)=>(s(t,e,"read from private field"),r?r.call(t):e.get(t)),w=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},p=(t,e,r,a)=>(s(t,e,"write to private field"),a?a.call(t,r):e.set(t,r),r),n;class o extends v{constructor(e){super(e);w(this,n,void 0),p(this,n,new l(e.connectNetwork??e.ceramic))}get threeId(){return d(this,n)}async authenticate(e,r=!0){const a=await this.connect(e);return await a.authenticate(),r&&(this.ceramic.did=a),a}async connect(e){return await d(this,n).connect(e),new f({provider:d(this,n).getDidProvider(),resolver:this.resolver})}}n=new WeakMap;var h=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)},c=(t,e,r)=>(h(t,e,"read from private field"),r?r.call(t):e.get(t)),_=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},D=(t,e,r,a)=>(h(t,e,"write to private field"),a?a.call(t,r):e.set(t,r),r),i;const u=class{constructor(t){if(_(this,i,void 0),!t.client.ceramic.did?.authenticated)throw new Error("Input DID must be authenticated, use SelfID.authenticate() instead of new SelfID()");D(this,i,t.client)}static async authenticate(t){const{authProvider:e,...r}=t,a=new o(r);return await a.authenticate(e,!0),new u({client:a})}get client(){return c(this,i)}get did(){const t=c(this,i).ceramic.did;if(t==null||!t.authenticated)throw new Error("Expected authenticated DID instance to be attached to Ceramic");return t}get id(){return this.did.id}async get(t){return await c(this,i).dataStore.get(t,this.did.id)}async set(t,e){return await c(this,i).dataStore.set(t,e)}async merge(t,e){return await c(this,i).dataStore.merge(t,e)}};let I=u;i=new WeakMap;export{k: EthereumAuthProvider,I: SelfID,o: WebClient} = pkg;

Call Stack
<unknown>
file:///Users/jon/code/ccl/commentor/node_modules/@self.id/web/dist/lib.mjs (1)
ModuleJob._instantiate
node:internal/modules/esm/module_job (124:21)
async ModuleJob.run
node:internal/modules/esm/module_job (181:5)
async ESMLoader.import
node:internal/modules/esm/loader (281:24)
async importModuleDynamicallyWrapper
node:internal/vm/module (437:15)

@jemgold
Copy link

jemgold commented Jan 12, 2022

@META-DREAMER idk if this was your issue but I fixed it with a tweak to my Next.js config vercel/next.js#30750 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants