Open aecorredor opened 6 years ago
@aecorredor I know next to nothing about React Native, so bear with me, but how are you passing the pre-built search index to search? Are you keeping it around in a global variable, or are you serializing it to some storage and then deserializing it before you search?
@hoelzro I build the index when the app launches and then keep it in my redux store so I can connect different components that might need search. Just an FYI there’s an issue open in RN for minification breaking some libraries; I tried the specified solution but had no luck. I don’t want to have to switch search libraries just for that, because it works on development and just breaks on release. So I guess it has to do with some part of the library being incorrectly minified for production.
@aecorredor From the look of that error message, I'm guessing that's the issue
@aecorredor do you have a link to the issue on RN for magnification problems? Might be worth updating the RN team with Lunr as a reproduction to help them test any fixes they have.
@oliviernn https://github.com/facebook/react-native/issues/9711
I had to switch to fuse.js for now which I didn’t want to do but had no other choice. I had already spent too much time figuring what part of the build process was breaking it. Hopefully we can figure it out. Cheers.
@aecorredor Thanks for the link. A brief look through it suggests that react native is using uglify for minification, this is what is used by Lunr for generating minified code so it certainly is a strange bug.
@olivernn no problem. And also, I kind of discarded that it was a bug on my code from the get go because on RN debug builds it works perfectly fine and it never crashes.
Any updates on using lunr + React Native?
@aecorredor @yaronlevi are you still having problems in recent RN versions? I'm on RN 0.55 and not getting a crash in a Release build when I call idx.search('test*');
@dave-irvine I ended up having to switch to fuse.js so I wouldn’t be able to tell you. Sorry mate.
I am quite confident that this issue with React Native was fixed by this PR:
https://github.com/olivernn/lunr.js/pull/361
The PR originally targeted a bug in Safari, and React Native on iOS uses the same JS engine as Safari.
I've been going through the issues like crazy to find something similar to what is happening to me. The closest one I've found is #279 and the possible solutions haven't worked. My app breaks when searching in the release build for some terms, but not when it's on debug mode. I've also gone through the react-native issues and have tried to fix the minify/uglify bugs but haven't been able to solve the problem I'm having. I get
TypeError: undefined is not an object (evaluating 'p._index')
when I call search with 'maine maine v v' for example. The weird thing is that in debug mode it works as expected, but in the release build it crashes.Here's my code for building the index, and my code for searching: