Merge pull request #11425 from meteor/react-fast-refresh-ie-fix

Fix react-fast-refresh for IE11
This commit is contained in:
Jan Dvorak
2021-05-12 21:22:44 +02:00
committed by GitHub
2 changed files with 11 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ if (enabled && process.env.NODE_ENV !== 'production' && module.hot) {
let timeout = null;
function scheduleRefresh() {
if (!timeout) {
timeout = setTimeout(() => {
timeout = setTimeout(function() {
timeout = null;
runtime.performReactRefresh();
}, 0);
@@ -69,11 +69,13 @@ if (enabled && process.env.NODE_ENV !== 'production' && module.hot) {
runtime.injectIntoGlobalHook(window);
window.$RefreshReg$ = () => { };
window.$RefreshSig$ = () => type => type;
window.$RefreshReg$ = function() { };
window.$RefreshSig$ = function() {
return function(type) { return type; };
};
module.hot.onRequire({
before(module) {
before: function(module) {
if (module.loaded) {
// The module was already executed
return;
@@ -83,18 +85,18 @@ if (enabled && process.env.NODE_ENV !== 'production' && module.hot) {
var prevRefreshSig = window.$RefreshSig$;
window.RefreshRuntime = runtime;
window.$RefreshReg$ = (type, _id) => {
window.$RefreshReg$ = function(type, _id) {
const fullId = module.id + ' ' + _id;
RefreshRuntime.register(type, fullId);
}
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
return {
prevRefreshReg,
prevRefreshSig
prevRefreshReg: prevRefreshReg,
prevRefreshSig: prevRefreshSig
};
},
after(module, beforeData) {
after: function(module, beforeData) {
// TODO: handle modules with errors
if (!beforeData) {
return;

View File

@@ -1,6 +1,6 @@
Package.describe({
name: 'react-fast-refresh',
version: '0.1.0',
version: '0.1.1',
summary: 'Automatically update React components with HMR',
documentation: 'README.md',
devOnly: true