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
Fix react-native example project #890
Conversation
The default plugin for validation, `is-my-json-valid`, depends on `generate-functions`, which uses core Node libraries and is therefore not usable outside of the core environment. Attempting the build the project before led to the following error: Unable to resolve module `util` from `<workspace/node_modules/generate_function/index.js`: Module `util` does not exist in the Haste module map The solution to this is to use AJV for validation instead. Also added try/catch around await statements, since that was the only way I could find this problem in the first place.
🤦♂️ It works on my computer. Without the change, it does not work. I don't know why. |
I'm not sure if this is an rxdb-problem. Does your error appear on build or on runtime? |
Okay, here's what I see:
and in the simulator you see the following:
The problem being that I believe that the problem is that jest runs tests on Node, completely hiding this problem. I feel like that is an annoying problem with the ecosystem, but I don't know any way to fix it with just jest. The only way I can think of to fix the erroneously-passing test suite is to add an actual end-to-end test using something like Detox or Cavy. The tests need to actually start up a simulator and load the app to show this error. |
I was going to begin work on a Detox test for this, since that project has documentation on running with Expo and with travis-CI, but I couldn't even build T_T. I filed wix/Detox#1145 and await a fix before I can use the tool. |
I could reproduce this problem locally. I am now looking into how to lets this fail the CI so I can ensure the problem will never reapear |
I could fix this. Please check out the new release. |
Works great! Thanks! |
The default plugin for validation,
is-my-json-valid
, depends ongenerate-functions
, which uses core Node libraries and is therefore not usableoutside of the Node environment. Attempting to build the project before led
to the following error:
The solution to this is to use AJV for validation instead, which requires using custom
build logic to determine which plugins are loaded.
Also added try/catch around await statements, since that was the only way I
could find this problem in the first place.
This PR contains:
bug fix; I have not included a test because the project would not build at all before.
Just building the project is the test :)
Todos
Although I only aimed to fix the react-native project in this PR, other non-node
environments will have the same problem. It would probably be better to provide
a built-in default plugin bundle for non-node environments.
This problem for non-node environments should probably be documented somewhere;
to me the preferable alternative would be to make AJV the default validation and tell
users that they can speed up performance on Node by using
is-my-json-valid
instead.Right now, RxDB may be broken out-of-the-box for many users.