joyhughes / Jen

Image processing, generative photography, cellular automata
https://discord.gg/GQQHUbkf
23 stars 20 forks source link

Replace create-react-app with Vite #74

Closed joyhughes closed 4 months ago

joyhughes commented 5 months ago

Project currently uses create react app which has been deprecated. Here is an article about alternatives to the tool: https://www.crocoder.dev/blog/create-react-app-is-dead-what-are-the-alternatives/

tarunsinghofficial commented 5 months ago

I think we can migrate to Vite + React. As CRA is deprecated in your project. What you think?

joyhughes commented 5 months ago

I think we can migrate to Vite + React. As CRA is deprecated in your project. What you think?

@tarunsinghofficial Have you used Vite + React before?

I checked it out and it looks promising.

The key question is if it's able to work with Emscipten. It was somewhat tricky to make Emscripten work with create-react-app (specifically, react-app-rewired), for which I used a guide written by Igor Prokurin https://dev.to/iprosk/cc-code-in-react-using-webassembly-7ka

There are examples out there of using Vite + React with Emscripten. Here is one: https://ppuzio.medium.com/c-in-the-browser-with-webassembly-via-emscripten-vite-and-react-bd82e0598a5e

We could build a simple example as they show in the article, then if it works well, migrate the app.

joyhughes commented 5 months ago

@tarunsinghofficial Let me know if you want to take this issue

joyhughes commented 5 months ago

Decision made to go with Vite

joyhughes commented 5 months ago

Here is another example project https://github.com/daxter-army/react-cpp-wasm-app

What the point person will need to do first is build a very simple "hello world" program using Emscripten and make that work using Vite+React. I linked an article for doing this in a previous comment https://ppuzio.medium.com/c-in-the-browser-with-webassembly-via-emscripten-vite-and-react-bd82e0598a5e but we could alternatively build Mehun's project. He may have used the same method anyway. Then when that is working drop in the Lux C++ code compiled with emscripten.

Then it should look exactly like it does now but using Vite which has advantages, mainly being supported but also speed and size. That will become the main branch. It will also be a way to learn about Emscripten which is a key part of the tech stack. No need to understand the internals of Lux for this step. Just build it and drop it in.

During this process I can also learn about Vite.

joyhughes commented 4 months ago

Branch created for this issue. Now critical priority!

karanmanglani commented 4 months ago

@joyhughes I can work on this issue. Please assign me this issue under GSSOC.

joyhughes commented 4 months ago

@joyhughes I can work on this issue. Please assign me this issue under GSSOC.

@khushhalgarg112 has worked on this issue some - he has got Emscripten to build. He or I might be able to help.

The best strategy I think is to make one of the examples work (using Vite + React with Emscripten), then when it is confirmed that it works use the same method with Lux.

joyhughes commented 4 months ago

@karanmanglani Learn more about project here: https://www.youtube.com/watch?v=vN1ApdESIrc Please ask any questions you may have

joyhughes commented 4 months ago

Please join Lux Vitae discord https://discord.gg/GQQHUbkf

joyhughes commented 4 months ago

I am looking into this issue now

joyhughes commented 4 months ago

I have started a Vite project. As the folder structure is different from create-react-app, I think the best strategy is to move the necessary files and build targets into the Vite project, and then have a new folder lux_vite and perhaps deprecate lux_react, replacing package-lock.json with a dummy file to fix the security warnings in issue #144

joyhughes commented 4 months ago

I have created the branch https://github.com/joyhughes/Jen/tree/Use-Vite

This is currently giving an error that seems to be related to MUI (perhaps a dependency not included)

Uncaught TypeError: undefined is not a function
    <anonymous> Box.js:9
RamakrushnaBiswal commented 4 months ago

@joyhughes assign it to me

joyhughes commented 4 months ago

I worked on this for many hours today and was successful in completing the migration to Vite.

This involved fixing Vite integration issues with both MUI and Emscripten.

PR soon

RamakrushnaBiswal commented 4 months ago

@joyhughes that's good

joyhughes commented 4 months ago

PR #152 closes issue