elmish / hmr

Hot Module Replacement for Elmish apps
https://elmish.github.io/hmr
Other
28 stars 8 forks source link

Wrap HMR code in try ... with #32

Closed alfonsogarciacaro closed 2 years ago

alfonsogarciacaro commented 2 years ago

Sorry @MangelMaxime, forgot to ask you in #30 to wrap the code for HMR with try ... with. This would be helpful because I recently tried to create a bundle with --define DEBUG but this didn't work because the bundle complained module was not defined (I assume something similar will happen with import.meta) when it was not served by a dev server like Webpack or Vite.

MangelMaxime commented 2 years ago

Yes vite was complaining about module being not defined this is why I put it on the top of the chain.

But I think that if people use an old version of Webpack they can have the same problem too according to message on Gitter.

I think I need to wrap each API in its own try ... with because otherwise if import is not defined it can probably break stuff.

MangelMaxime commented 2 years ago

Version 4.3.0 should fix this error.

I completely reworked how it was implemented making the code is now cleaner and handling correctly cases like this one.