Skip to content

Commit

Permalink
Revert runtime changes
Browse files Browse the repository at this point in the history
  • Loading branch information
101arrowz committed May 29, 2022
1 parent c191057 commit d9de031
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 39 deletions.
39 changes: 8 additions & 31 deletions packages/runtimes/webextension/src/autoreload-bg.js
@@ -1,29 +1,5 @@
/* global chrome, browser, addEventListener, fetch, Response, HMR_HOST, HMR_PORT */
var env = typeof chrome == 'undefined' ? browser : chrome;
var autoReload = false;

var origReload = env.runtime.reload;
env.runtime.reload = function () {
var reloadOnce = false;
function reloadTabs(tabs) {
for (let i = 0; i < tabs.length; ++i) {
env.tabs.sendMessage(
tabs[i].id,
{__parcel_hmr_reload__: true},
{},
function () {},
);
}
if (reloadOnce) {
origReload.call(env.runtime);
} else {
reloadOnce = true;
}
}
env.tabs.query({highlighted: true}, reloadTabs);
env.tabs.query({highlighted: false}, reloadTabs);
};

env.runtime.onMessage.addListener(function (msg) {
if (msg.__parcel_hmr_reload__) {
env.runtime.reload();
Expand All @@ -38,13 +14,14 @@ if (env.runtime.getManifest().manifest_version == 3) {
url = new URL(decodeURIComponent(url.slice(proxyLoc.length)));
if (url.hostname == HMR_HOST && url.port == HMR_PORT) {
evt.respondWith(
fetch(url).then(function (res) {
return new Response(res.body, {
headers: {
'Content-Type': res.headers.get('Content-Type'),
},
});
}),
fetch(url).then(
res =>
new Response(res.body, {
headers: {
'Content-Type': res.headers.get('Content-Type'),
},
}),
),
);
}
}
Expand Down
8 changes: 0 additions & 8 deletions packages/transformers/webextension/src/runtime/autoreload.js
Expand Up @@ -9,11 +9,3 @@ addEventListener('beforeunload', function () {
// ignore throwing if extension context invalidated
}
});

env.runtime.onMessage.addListener(function (msg) {
if (msg.__parcel_hmr_reload__) {
setTimeout(function () {
location.reload();
}, 50);
}
});

0 comments on commit d9de031

Please sign in to comment.