geosolutions-it / MapStore2

The solution to create and share maps, dashboards, geostories with 3D support on the web. And it is open-source too!
https://mapstore.geosolutionsgroup.com/
Other
505 stars 391 forks source link

React 18 and VITE for fast hot reload #9848

Open flieks opened 9 months ago

flieks commented 9 months ago

Description

The current react app has slow hot reload which is bad for productivity.

Upgrading to react 18 makes sense, being compatible with newer libraries and then its compatible with VITE esbuild system which offers very fast hot reload. Work involved is changing all require imports to es module imports, and configuring vite so it replaces the current webpack configuration.

What kind of improvement you want to add? (check one with "x", remove the others)

flieks commented 9 months ago

I changed all of require() imports to ESM module imports and renamed .js to .jsx but still there is some issue with WithExtensions as shown in stacktrace:

    in StandardRouter
    in Connect(StandardRouter) (created by DragDropContext(Connect(StandardRouter)))
    in DragDropContext(Connect(StandardRouter))
    in Provider2
    in StandardApp
    in WithExtensions

with error:

react-dom.development.js:12251  Uncaught Invariant Violation: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
flieks commented 8 months ago

its something to do with the hooks inside Theme.js.

If i remove the hooks there, it can render something

flieks commented 8 months ago

Are there any plans to move away from slow webpack ?

offtherailz commented 8 months ago

Hi, for the moment there are no plans to switch the vite. But fixing compatibility with next versions of react and alignign the module syntax is good for future in any case.