submillisecond-live-view icon indicating copy to clipboard operation
submillisecond-live-view copied to clipboard

Integrating Svelte

Open pcharbon70-leco opened this issue 1 year ago • 2 comments

Good afternoon,

This is not an issue per say but more of a question about integrating a module like Svelte in the build process. I read a very interesting article a few weeks back about E2E Reactivity using Svelte with Phoenix Liveview that inspired some people to develop an integration between Phoenix Liveview and Svelte.

I know that you can compile Svelte to WASM but that would not let submillisecond-live-view directly interact with it in order to capture the events from Svelt. I don't mind spending the time trying to see how to achieve this but I am not sure if there is any way to actually integrate NPM build process with submillisecond server at the moment? Still totally new to the lunatic way of things to be honest.

Any pointer in the right direction would be appreciated.

Thank you in advance.

Pascal Charbonneau

pcharbon70-leco avatar Aug 14 '23 17:08 pcharbon70-leco

submillisecond-live-view projects use Rust's default package manager/build tool cargo.

Inside of the cargo project you can add a build.rs file that will run arbitrary code on each build and, I assume, can be used to trigger an NPM build. https://doc.rust-lang.org/cargo/reference/build-scripts.html

There are also helper libraries that let you do this https://github.com/UpsettingBoy/npm_rs

bkolobara avatar Aug 18 '23 07:08 bkolobara

Thanks for the explanation and links, they should help. Looking forward to trying lunatic as an Elixir developer and Rust newbie. Its really like eating your cake and having it too :)

pcharbon70-leco avatar Aug 18 '23 08:08 pcharbon70-leco