-
Notifications
You must be signed in to change notification settings - Fork 10
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
Webpack+React build #4
Comments
yes this is the problem, it can only be used in a vanilla-js context atm |
Let me know if there is anything I can do to help with getting this working with JS bundlers. At a bare minimum I can help test as I have a PWA I am working on currently, but if there are some next steps that you have in mind, feel free to hit me up! |
On Thu, Jul 21, 2022 at 10:12:43PM -0700, Aaron wrote:
Let me know if there is anything I can do to help with getting this working with JS bundlers. At a bare minimum I can help test as I have a PWA I am working on currently, but if there are some next steps that you have in mind, feel free to hit me up!
unless there's an easy way to package emscripten wasm builds into webpack... I might have to just create a pure js version of lnsocket...
|
I think that in most modern bundlers like Webpack and Vite you can directly import wasm files. So maybe the wasm could be compiled without the "glue" js code and then a small module could be written that interfaces with the wasm file? Then for the lnsocket package you could import the wasm file as well as the javascript module, load up the wasm and then init the js file passing the initialised wasm file to it? I found some links that might be useful: I don't have any experience using emscripten and others, but i'll do some more digging. Hopefully writing a pure js version can be avoided. |
I have it working in a Svelte PWA now as is by loading it in via script tag which works pretty well. For some reason I couldn't get it to work that way in a Sveltekit project 🤷♂️ |
For anyone else looking for a solution for use in Webpack, Vite, Rollup projects, you can check out a JS version of lnsocket that I have created for easy integration with web browser bundles. |
Webpack does static analysis on the emscripten module and complains when it sees nodejs 'require' statements, even if they are never called in practice.
It also breaks when trying to pack the wasm module. If we get a local webpack build working and distribute that to npm, then lnsocket should work out of the box for React projects.
The text was updated successfully, but these errors were encountered: