You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As it stands right now Vite HMR API is quite awesome and covers the majority if not all of the possible needs for us devs.
Nonetheless, sometimes seems to be necessary to have knowledge of how the module exports look like. This is something that one can get via import.meta.hot.accept(module => ...); nonetheless, this will only trigger during a hot update. There are hmr implementations that depend on the module, like the react-hot-loader. Or to implement a more robust @vitejs/plugin-react-refresh where we one can delegate the registration of class components (which right now it doesn't allow), to the runtime with something that would look roughly: RefreshRuntime.isReactRefreshBoundary(module) where isReactRefreshBoundary:
exportfunctionisReactRefreshBoundary(moduleExports){for(letkeyinmoduleExports){let_c=moduleExports[key];if(RefreshRuntime.isLikelyComponentType(_c)){$RefreshReg$(_c,_c.displayName||_c.name);}}if(RefreshRuntime.isLikelyComponentType(moduleExports)){returntrue;}if(moduleExports==null||typeofmoduleExports!=='object'){// Exit if we can't iterate over exports.returnfalse;}lethasExports=false;letareAllExportsComponents=true;for(constkeyinmoduleExports){hasExports=true;if(key==='__esModule'){continue;}constdesc=Object.getOwnPropertyDescriptor(moduleExports,key);if(desc&&desc.get){// Don't invoke getters as they may have side effects.returnfalse;}constexportValue=moduleExports[key];if(!RefreshRuntime.isLikelyComponentType(exportValue)){areAllExportsComponents=false;}}returnhasExports&&areAllExportsComponents;};
Maybe to follow a little bit, it could be exposed under: import.meta.module or import.meta.hot.module 🤔 ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
As it stands right now Vite HMR API is quite awesome and covers the majority if not all of the possible needs for us devs.
Nonetheless, sometimes seems to be necessary to have knowledge of how the
module
exports look like. This is something that one can get viaimport.meta.hot.accept(module => ...)
; nonetheless, this will only trigger during a hot update. There arehmr
implementations that depend on themodule
, like thereact-hot-loader
. Or to implement a more robust@vitejs/plugin-react-refresh
where we one can delegate the registration of class components (which right now it doesn't allow), to the runtime with something that would look roughly:RefreshRuntime.isReactRefreshBoundary(module)
whereisReactRefreshBoundary
:Maybe to follow a little bit, it could be exposed under:
import.meta.module
orimport.meta.hot.module
🤔 ?Beta Was this translation helpful? Give feedback.
All reactions