-
Notifications
You must be signed in to change notification settings - Fork 25
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
onSnapshot and onPatches fail when called from an external module #443
Comments
are you using yarn 2 or 3 by any chance? |
1.22.18 |
pulled in Keystone Container owing to this issue: xaviergonz/mobx-keystone#443
I'm afraid without an example project or something I can't help much. If you are using yarn v3 then you need to hoist it manually, this is, set it as peer dep in both packages (the lib and the app) and adding it as a dep to the root package.json. Actually you may try to do that with yarn v1 too, maybe it will work. |
I can try to put together a simple example to demonstrate the issue. Do you have any examples where the lib approach works? |
I've seen it working, but on private code. |
I have a working solution in a typescript project. When I watch for changes using onSnapshot and onPatches within that project, it works perfectly. However when I move the exact same code to a library and include it, the method fails with the following error:
Error: subtreeRoot must be a tree node (usually a model or a shallow / deep child part of a model 'data' object)
I thought there might be a version clash between the keystone dependencies, but I have tried used peer dependencies as well as ensuring that the referenced versions are identical.
When I debug I can confirm that the issue is arising because tweakedObjects in the local instance contains the object, but when used as a module, it does not. It looks like these WeakMaps are being declared at the module root. If that's the case then I guess it makes sense why keystone wouldn't work correctly across modules. Does anyone know how to address this issue?
Call stack:
The text was updated successfully, but these errors were encountered: