I'm expecting this to be the hardest use case to support, given React's CJS reliance. But, Snowpack can now install React as ESM, so maybe we're not as far away from supporting Fast Refresh as I'd thought.
@gaearon would love your feedback on this one. Based on your code snippets in that thread, it looks like your HMR API needs are actually pretty simple. I only see use of module.hot.accept() without any arguments. It appears that most of the complexity lives in properly connecting react-refresh/runtime into your app, which is outside the scope of this spec.
Any specific HMR API requirements needed other than import.meta.hot.accept()? Any more detailed implementations that you'd recommend checking out?
The main different between ESM-HMR and bundler-specific HMR APIs is that the first loaded module is the only copy of that module ever connected to the app. Instead of having new modules replace old ones, the import.meta.hot.accept(({module}) => ...) method is always responsible for updating the original module using the exports of the updated module.
/cc @gaearon Context: https://github.com/facebook/react/issues/16604#issuecomment-528663101
I'm expecting this to be the hardest use case to support, given React's CJS reliance. But, Snowpack can now install React as ESM, so maybe we're not as far away from supporting Fast Refresh as I'd thought.
@gaearon would love your feedback on this one. Based on your code snippets in that thread, it looks like your HMR API needs are actually pretty simple. I only see use of
module.hot.accept()
without any arguments. It appears that most of the complexity lives in properly connectingreact-refresh/runtime
into your app, which is outside the scope of this spec.Any specific HMR API requirements needed other than
import.meta.hot.accept()
? Any more detailed implementations that you'd recommend checking out?The main different between ESM-HMR and bundler-specific HMR APIs is that the first loaded module is the only copy of that module ever connected to the app. Instead of having new modules replace old ones, the
import.meta.hot.accept(({module}) => ...)
method is always responsible for updating the original module using the exports of the updated module.