Skip to content
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

Open
jb55 opened this issue Apr 9, 2022 · 7 comments
Open

Webpack+React build #4

jb55 opened this issue Apr 9, 2022 · 7 comments

Comments

@jb55
Copy link
Owner

jb55 commented Apr 9, 2022

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.

@lnbc1QWFyb24
Copy link

I tried including in a vite.js project via installing from NPM and I get the following error after importing:

Screen Shot 2022-07-11 at 1 35 59 pm

@jb55
Copy link
Owner Author

jb55 commented Jul 11, 2022

yes this is the problem, it can only be used in a vanilla-js context atm

@lnbc1QWFyb24
Copy link

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!

@jb55
Copy link
Owner Author

jb55 commented Jul 22, 2022 via email

@lnbc1QWFyb24
Copy link

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:
https://stackoverflow.com/questions/45295339/can-i-somehow-build-webassembly-code-without-the-emscripten-glue

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.

@lnbc1QWFyb24
Copy link

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 🤷‍♂️

@lnbc1QWFyb24
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants