Open geofmureithi-zz opened 4 years ago
Did you find a workaround for this? I'm running into the same problem running in Nodejs with indexeddbshim.
The addons are not designed to run on node. I know we made a job to make Dexie itself run on node with indexeddbshim even though not perfectly. However, in nextjs I don't see the use case to use the addons server-side. This particular error is probably easily fixed, but the question is how the intent is to use those addons on node. There might be other errors to haunt down than these before these addons runs on node. I'm not so experienced with next.js but I suppose there is a way to skip importing the addons server-side.
@carsonfarmer dynamic imports work. Another trick could be using https://github.com/ds300/patch-package though I haven't tried it
Edit: my answer might not be applicable specifically to node.
Thanks @geofmureithi. For now, I'm able to work around this by writing in Typescript and compiling to CommonJS (which I'm doing anyway), but that seems fragile, so the dynamic imports might be the best route.
Also fair enough @dfahlander, though there are plenty of legitimate use-cases for having something like dexie-syncable
running in node to sync updates across "peers". In my case, it is about having (mostly) isomorphic code that runs similarly in node and the browser. So far, things appear to be working quite well, other than a few assumptions such as the one touched on in this issue 🤞 .
@carsonfarmer I see about the value of isomorphism. The question is whether the server-part would be a client to another sync server, or if the server part itself should represent the sync server (using something similar to this or sync-server).
In my case, possibly both. I am looking at a "hybrid" network of clients and servers, some of which operate in a browser, and some of which operate in node, but only one (depending on the network setup) is going to be the sync server at a time.
Anyway, didn't want to derail the issue here. The above discussion seems to have mostly addressed things, or provided sufficient justification for why things are the way they are :)
Here are the steps to recreate the bug.
package.json
I then created a file
src/db.js
with the following contents:Then in
index.js
,Running
yarn dev
returns the following error:Removing the line does seem to fix the issue.