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
Natural (stemming dependency) crashes in browser #31
Comments
Possibly related to NaturalNode/natural#368 |
I've been taking a look at this for a few hours now, I think there's a bunch of things going on here:
So I think the tl;dr is that this library won't "just work" on web for newer build tools, because natural won't. I think it would be pretty easy to get this working with e.g. webpack v4 (although I haven't confirmed this) but that's not much use as the whole FE ecosystem is already moved on from that. Alternatively it could be worth opening an issue on the natural repo to see if they'd be interested in updating their check for threading support, or even using web workers if they're available natively (e.g. in browser, deno, electron environments) as it looks like the library they're using is modelled on the web worker standard anyway. |
Upon a quick look, I don't think Natural works in the browser, see the many issues closed on the topic. This specific error can be easily bypassed by configuring vite in this way so it ignores dynamic imports, but once you do that you'll see other errors coming up due to Natural using many Node-specific APIs which I'm not sure how easy or feasible it is to export default defineConfig({
plugins: [react(), Unocss({})],
build: {
target: ["es2020"],
commonjsOptions: {
ignoreDynamicRequires: true
}
},
}); |
Thank you @silawrenc and @simoneb, this analysis is crystal clear. Natural is becoming more and more complex to maintain in this codebase, and this issue specifically is a blocker. So I'll close this issue and open a new one to migrate to a different stemming library. Thanks again 🙏 |
Describe the bug
When running Lyra in a browser, you will get the following error:
To Reproduce
Steps to reproduce the behavior:
packages/examples/with-react
directorypnpm dev
http://localhost:3000
and open the development consoleExpected behavior
Lyra should work out of the box on browsers
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: