elmish / hmr

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

Add comment to import.meta.hot #35 #36

Closed olivercoad closed 2 years ago

olivercoad commented 2 years ago

I didn't add it to all the emits in HMR.Vite.fs. Is there a reason it's not just a single emit over let hot = ... like in HMR.Webpack.fs?

MangelMaxime commented 2 years ago

Is there a reason it's not just a single emit over let hot = ... like in HMR.Webpack.fs?

What do you mean by that?


~I didn't add the comment to all the lines because HMR.Vite is the first one to be checked so, it will always be the first one to fail and report the error.~

I just saw your comment under the original issue. I will review and test the PR later.

MangelMaxime commented 2 years ago

The syntax import.meta.webpackHot in HMR.Webpack is not an error.

Webpack exposed the hot API via import.meta.webpackHot and import.meta.hot

If you tested the PR and had the sentiment it was working it is because Webpack also expose the hot API via module.hot.

olivercoad commented 2 years ago

I know. I was asking in HMR.Vite why does each abstract method in IHot have its own emit and let hot marked as global. Instead of not having emits over every abstract method like in webpack and parcel.

On Fri., 26 Nov. 2021, 23:58 Maxime Mangel, @.***> wrote:

Merged #36 https://github.com/elmish/hmr/pull/36 into master.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/elmish/hmr/pull/36#event-5677554794, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF5P62SZI5UUTMBPN7M4I3TUN6AA5ANCNFSM5IZJ5ADA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

MangelMaxime commented 2 years ago

This is because Vite is very strict about how the JavaScript code should be written.

And if we do the "normal Fable way", then Fable will generate something like (import.meta.hot).data and Vite will not detect it.

Doing this way, makes sure that we don't have extra parenthesis added.