PrismarineJS / prismarine-web-client

Minecraft web client running in your browser
https://prismarinejs.github.io/prismarine-web-client/
MIT License
444 stars 144 forks source link

Migrate to Vite? #253

Open zardoy opened 2 years ago

zardoy commented 2 years ago

It Might resolve https://github.com/PrismarineJS/prismarine-web-client/issues/210 in a better way.

Its kinda popular alternative, have you ever tried it? For me in projects at any scale it always served an extreme performance. For now I’m just asking here, will try it here in a few days.

rom1504 commented 2 years ago

try it, if it works faster without breaking things then let's do it yet

zardoy commented 2 years ago

I tried it in https://github.com/PrismarineJS/prismarine-viewer/tree/master/examples/standalone. Kinda fast, but doesn't work at all. Polyfilling node with it is much harder than I expected (they're doing it on purpose as its not recommended).

And also about this repo, Vite would punish you for 500kb bundle size, but here, index.js have ~35mb. Have you thought about getting rid of polyfilling node in favor of more clean solution?

Anyway, I'll keep exploring ways to make it work :

rom1504 commented 2 years ago

What would be a more clean solution?

rom1504 commented 2 years ago

re-open if you feel like investigating this more deeply

zardoy commented 2 years ago

I really wanted to see it here, but unfortunately didn't have much time recently :( I'll try to take a fresh look into it in next year.

What would be a more clean solution?

Get rid of polyfylling node modules. As I mentioned above, Vite is a modern alternative to webpack with builtin dev server and blazing performance, however it has some drawbacks. For example, it's hard (or I just didn't find an easy way) to polyfil node. However they support Rollup plugins, so, again, there should be a way...

Btw, with Snowpack it was extremely easy. It supported --polyfil-node flag so you could just run snowpack --polyfil-node and I would do all the magic for you (even without creating a config file), however it's not maintained anymore.

Hope I made it clear, feel free correct me.

rom1504 commented 2 years ago

ok let's re-open to discuss

rom1504 commented 2 years ago

Get rid of polyfylling node modules.

yes I'm asking about your solution to do that and that would be cleaner than polyfilling

rom1504 commented 2 years ago

For example, it's hard (or I just didn't find an easy way) to polyfil node

supporting node modules is the main reason why we use webpack to begin with, so that doesn't seem to work here

rom1504 commented 2 years ago

something interesting is that webpack is going straight in the wrong direction by removing all the polyfilling by default it seems that browserify is still the best bundler, maybe we should go back to it

AwesomestCode commented 2 years ago

I will note that dev build performance has magically increased a lot recently for me though

zardoy commented 1 year ago

Hi all! How's it going? I've finally managed to put my focus on this fantastic project (I've promised sandboxed mc to a lot of folks). I've already included a few cool changes in my fork and have even more ideas to implement soon!

Btw what about Vite, it turns out it wasn't that hard to polyfill node modules (though it still doesn't support false aliases). eg prismarine-viewer works fine with Vite setup, however, the performance is still far from ideal... I will continue investigating it.

What I really miss from the current setup is the hot reload. eg if I make any changes I need to fully reload the page, reconnect, and so on...

Are there other changes you might be interested in? i see some code parts are hid/in corect