@atlaspack/runtime-browser-hmr 2.12.1-dev.3368 → 2.12.1-dev.3401
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/loaders/hmr-runtime.js +31 -31
- package/package.json +5 -5
- package/src/loaders/hmr-runtime.js +32 -35
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser,
|
|
3
|
+
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser, __parcel__import__, __parcel__importScripts__, ServiceWorkerGlobalScope */
|
|
4
4
|
/*::
|
|
5
5
|
import type {
|
|
6
6
|
HMRAsset,
|
|
7
7
|
HMRMessage,
|
|
8
8
|
} from '@atlaspack/reporter-dev-server/src/HMRServer.js';
|
|
9
|
-
interface
|
|
9
|
+
interface ParcelRequire {
|
|
10
10
|
(string): mixed;
|
|
11
|
-
cache: {|[string]:
|
|
11
|
+
cache: {|[string]: ParcelModule|};
|
|
12
12
|
hotData: {|[string]: mixed|};
|
|
13
13
|
Module: any;
|
|
14
|
-
parent: ?
|
|
15
|
-
|
|
14
|
+
parent: ?ParcelRequire;
|
|
15
|
+
isParcelRequire: true;
|
|
16
16
|
modules: {|[string]: [Function, {|[string]: string|}]|};
|
|
17
17
|
HMR_BUNDLE_ID: string;
|
|
18
|
-
root:
|
|
18
|
+
root: ParcelRequire;
|
|
19
19
|
}
|
|
20
|
-
interface
|
|
20
|
+
interface ParcelModule {
|
|
21
21
|
hot: {|
|
|
22
22
|
data: mixed,
|
|
23
23
|
accept(cb: (Function) => void): void,
|
|
@@ -35,7 +35,7 @@ interface ExtensionContext {
|
|
|
35
35
|
getManifest(): {manifest_version: number, ...};
|
|
36
36
|
|};
|
|
37
37
|
}
|
|
38
|
-
declare var module: {bundle:
|
|
38
|
+
declare var module: {bundle: ParcelRequire, ...};
|
|
39
39
|
declare var HMR_HOST: string;
|
|
40
40
|
declare var HMR_PORT: string;
|
|
41
41
|
declare var HMR_ENV_HASH: string;
|
|
@@ -43,12 +43,12 @@ declare var HMR_SECURE: boolean;
|
|
|
43
43
|
declare var HMR_USE_SSE: boolean;
|
|
44
44
|
declare var chrome: ExtensionContext;
|
|
45
45
|
declare var browser: ExtensionContext;
|
|
46
|
-
declare var
|
|
47
|
-
declare var
|
|
46
|
+
declare var __parcel__import__: (string) => Promise<void>;
|
|
47
|
+
declare var __parcel__importScripts__: (string) => Promise<void>;
|
|
48
48
|
declare var globalThis: typeof self;
|
|
49
49
|
declare var ServiceWorkerGlobalScope: Object;
|
|
50
50
|
*/
|
|
51
|
-
var OVERLAY_ID = '
|
|
51
|
+
var OVERLAY_ID = '__parcel__error__overlay__';
|
|
52
52
|
var OldModule = module.bundle.Module;
|
|
53
53
|
function Module(moduleName) {
|
|
54
54
|
OldModule.call(this, moduleName);
|
|
@@ -67,7 +67,7 @@ function Module(moduleName) {
|
|
|
67
67
|
}
|
|
68
68
|
module.bundle.Module = Module;
|
|
69
69
|
module.bundle.hotData = {};
|
|
70
|
-
var checkedAssets /*: {|[string]: boolean|} */, assetsToDispose /*: Array<[
|
|
70
|
+
var checkedAssets /*: {|[string]: boolean|} */, assetsToDispose /*: Array<[ParcelRequire, string]> */, assetsToAccept /*: Array<[ParcelRequire, string]> */;
|
|
71
71
|
|
|
72
72
|
function getHostname() {
|
|
73
73
|
return HMR_HOST || (location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost');
|
|
@@ -78,13 +78,13 @@ function getPort() {
|
|
|
78
78
|
|
|
79
79
|
// eslint-disable-next-line no-redeclare
|
|
80
80
|
var parent = module.bundle.parent;
|
|
81
|
-
if ((!parent || !parent.
|
|
81
|
+
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
|
82
82
|
var hostname = getHostname();
|
|
83
83
|
var port = getPort();
|
|
84
84
|
var protocol = HMR_SECURE || location.protocol == 'https:' && !['localhost', '127.0.0.1', '0.0.0.0'].includes(hostname) ? 'wss' : 'ws';
|
|
85
85
|
var ws;
|
|
86
86
|
if (HMR_USE_SSE) {
|
|
87
|
-
ws = new EventSource('/
|
|
87
|
+
ws = new EventSource('/__parcel_hmr');
|
|
88
88
|
} else {
|
|
89
89
|
try {
|
|
90
90
|
ws = new WebSocket(protocol + '://' + hostname + (port ? ':' + port : '') + '/');
|
|
@@ -132,7 +132,7 @@ if ((!parent || !parent.isAtlaspackRequire) && typeof WebSocket !== 'undefined')
|
|
|
132
132
|
|
|
133
133
|
// Dispatch custom event so other runtimes (e.g React Refresh) are aware.
|
|
134
134
|
if (typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') {
|
|
135
|
-
window.dispatchEvent(new CustomEvent('
|
|
135
|
+
window.dispatchEvent(new CustomEvent('parcelhmraccept'));
|
|
136
136
|
}
|
|
137
137
|
await hmrApplyUpdates(assets);
|
|
138
138
|
|
|
@@ -158,10 +158,10 @@ if ((!parent || !parent.isAtlaspackRequire) && typeof WebSocket !== 'undefined')
|
|
|
158
158
|
} else fullReload();
|
|
159
159
|
}
|
|
160
160
|
if (data.type === 'error') {
|
|
161
|
-
// Log
|
|
161
|
+
// Log parcel errors to console
|
|
162
162
|
for (let ansiDiagnostic of data.diagnostics.ansi) {
|
|
163
163
|
let stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack;
|
|
164
|
-
console.error('🚨 [
|
|
164
|
+
console.error('🚨 [parcel]: ' + ansiDiagnostic.message + '\n' + stack + '\n\n' + ansiDiagnostic.hints.join('\n'));
|
|
165
165
|
}
|
|
166
166
|
if (typeof document !== 'undefined') {
|
|
167
167
|
// Render the fancy html overlay
|
|
@@ -179,7 +179,7 @@ if ((!parent || !parent.isAtlaspackRequire) && typeof WebSocket !== 'undefined')
|
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
ws.onclose = function () {
|
|
182
|
-
console.warn('[
|
|
182
|
+
console.warn('[parcel] 🚨 Connection to the HMR server was lost');
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
}
|
|
@@ -187,7 +187,7 @@ function removeErrorOverlay() {
|
|
|
187
187
|
var overlay = document.getElementById(OVERLAY_ID);
|
|
188
188
|
if (overlay) {
|
|
189
189
|
overlay.remove();
|
|
190
|
-
console.log('[
|
|
190
|
+
console.log('[parcel] ✨ Error resolved');
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
function createErrorOverlay(diagnostics) {
|
|
@@ -197,7 +197,7 @@ function createErrorOverlay(diagnostics) {
|
|
|
197
197
|
for (let diagnostic of diagnostics) {
|
|
198
198
|
let stack = diagnostic.frames.length ? diagnostic.frames.reduce((p, frame) => {
|
|
199
199
|
return `${p}
|
|
200
|
-
<a href="/
|
|
200
|
+
<a href="/__parcel_launch_editor?file=${encodeURIComponent(frame.location)}" style="text-decoration: underline; color: #888" onclick="fetch(this.href); return false">${frame.location}</a>
|
|
201
201
|
${frame.code}`;
|
|
202
202
|
}, '') : diagnostic.stack;
|
|
203
203
|
errorHTML += `
|
|
@@ -224,7 +224,7 @@ function fullReload() {
|
|
|
224
224
|
extCtx.runtime.reload();
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
function getParents(bundle, id) /*: Array<[
|
|
227
|
+
function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */{
|
|
228
228
|
var modules = bundle.modules;
|
|
229
229
|
if (!modules) {
|
|
230
230
|
return [];
|
|
@@ -299,11 +299,11 @@ function hmrDownload(asset) {
|
|
|
299
299
|
} else if (typeof importScripts === 'function') {
|
|
300
300
|
// Worker scripts
|
|
301
301
|
if (asset.outputFormat === 'esmodule') {
|
|
302
|
-
return
|
|
302
|
+
return __parcel__import__(asset.url + '?t=' + Date.now());
|
|
303
303
|
} else {
|
|
304
304
|
return new Promise((resolve, reject) => {
|
|
305
305
|
try {
|
|
306
|
-
|
|
306
|
+
__parcel__importScripts__(asset.url + '?t=' + Date.now());
|
|
307
307
|
resolve();
|
|
308
308
|
} catch (err) {
|
|
309
309
|
reject(err);
|
|
@@ -314,7 +314,7 @@ function hmrDownload(asset) {
|
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
316
|
async function hmrApplyUpdates(assets) {
|
|
317
|
-
global.
|
|
317
|
+
global.parcelHotUpdate = Object.create(null);
|
|
318
318
|
let scriptsToRemove;
|
|
319
319
|
try {
|
|
320
320
|
// If sourceURL comments aren't supported in eval, we need to load
|
|
@@ -341,7 +341,7 @@ async function hmrApplyUpdates(assets) {
|
|
|
341
341
|
hmrApply(module.bundle.root, asset);
|
|
342
342
|
});
|
|
343
343
|
} finally {
|
|
344
|
-
delete global.
|
|
344
|
+
delete global.parcelHotUpdate;
|
|
345
345
|
if (scriptsToRemove) {
|
|
346
346
|
scriptsToRemove.forEach(script => {
|
|
347
347
|
if (script) {
|
|
@@ -352,7 +352,7 @@ async function hmrApplyUpdates(assets) {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
function hmrApply(bundle /*:
|
|
355
|
+
function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
|
|
356
356
|
var modules = bundle.modules;
|
|
357
357
|
if (!modules) {
|
|
358
358
|
return;
|
|
@@ -383,7 +383,7 @@ function hmrApply(bundle /*: AtlaspackRequire */, asset /*: HMRAsset */) {
|
|
|
383
383
|
}
|
|
384
384
|
|
|
385
385
|
// $FlowFixMe
|
|
386
|
-
let fn = global.
|
|
386
|
+
let fn = global.parcelHotUpdate[asset.id];
|
|
387
387
|
modules[asset.id] = [fn, deps];
|
|
388
388
|
} else if (bundle.parent) {
|
|
389
389
|
hmrApply(bundle.parent, asset);
|
|
@@ -418,7 +418,7 @@ function hmrDelete(bundle, id) {
|
|
|
418
418
|
hmrDelete(bundle.parent, id);
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
|
-
function hmrAcceptCheck(bundle /*:
|
|
421
|
+
function hmrAcceptCheck(bundle /*: ParcelRequire */, id /*: string */, depsByBundle /*: ?{ [string]: { [string]: string } }*/) {
|
|
422
422
|
if (hmrAcceptCheckOne(bundle, id, depsByBundle)) {
|
|
423
423
|
return true;
|
|
424
424
|
}
|
|
@@ -445,7 +445,7 @@ function hmrAcceptCheck(bundle /*: AtlaspackRequire */, id /*: string */, depsBy
|
|
|
445
445
|
}
|
|
446
446
|
return accepted;
|
|
447
447
|
}
|
|
448
|
-
function hmrAcceptCheckOne(bundle /*:
|
|
448
|
+
function hmrAcceptCheckOne(bundle /*: ParcelRequire */, id /*: string */, depsByBundle /*: ?{ [string]: { [string]: string } }*/) {
|
|
449
449
|
var modules = bundle.modules;
|
|
450
450
|
if (!modules) {
|
|
451
451
|
return;
|
|
@@ -469,7 +469,7 @@ function hmrAcceptCheckOne(bundle /*: AtlaspackRequire */, id /*: string */, dep
|
|
|
469
469
|
return true;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
function hmrDispose(bundle /*:
|
|
472
|
+
function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
|
|
473
473
|
var cached = bundle.cache[id];
|
|
474
474
|
bundle.hotData[id] = {};
|
|
475
475
|
if (cached && cached.hot) {
|
|
@@ -482,7 +482,7 @@ function hmrDispose(bundle /*: AtlaspackRequire */, id /*: string */) {
|
|
|
482
482
|
}
|
|
483
483
|
delete bundle.cache[id];
|
|
484
484
|
}
|
|
485
|
-
function hmrAccept(bundle /*:
|
|
485
|
+
function hmrAccept(bundle /*: ParcelRequire */, id /*: string */) {
|
|
486
486
|
// Execute the module.
|
|
487
487
|
bundle(id);
|
|
488
488
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/runtime-browser-hmr",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3401+b483af77f",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"source": "src/HMRRuntime.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">= 16.0.0",
|
|
16
|
-
"
|
|
16
|
+
"parcel": "^2.12.1-dev.3401+b483af77f"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/plugin": "2.12.1-dev.
|
|
20
|
-
"@atlaspack/utils": "2.12.1-dev.
|
|
19
|
+
"@atlaspack/plugin": "2.12.1-dev.3401+b483af77f",
|
|
20
|
+
"@atlaspack/utils": "2.12.1-dev.3401+b483af77f"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "b483af77f02d1258c8dad156e097b94f83671d8e"
|
|
23
23
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser,
|
|
2
|
+
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser, __parcel__import__, __parcel__importScripts__, ServiceWorkerGlobalScope */
|
|
3
3
|
|
|
4
4
|
/*::
|
|
5
5
|
import type {
|
|
6
6
|
HMRAsset,
|
|
7
7
|
HMRMessage,
|
|
8
8
|
} from '@atlaspack/reporter-dev-server/src/HMRServer.js';
|
|
9
|
-
interface
|
|
9
|
+
interface ParcelRequire {
|
|
10
10
|
(string): mixed;
|
|
11
|
-
cache: {|[string]:
|
|
11
|
+
cache: {|[string]: ParcelModule|};
|
|
12
12
|
hotData: {|[string]: mixed|};
|
|
13
13
|
Module: any;
|
|
14
|
-
parent: ?
|
|
15
|
-
|
|
14
|
+
parent: ?ParcelRequire;
|
|
15
|
+
isParcelRequire: true;
|
|
16
16
|
modules: {|[string]: [Function, {|[string]: string|}]|};
|
|
17
17
|
HMR_BUNDLE_ID: string;
|
|
18
|
-
root:
|
|
18
|
+
root: ParcelRequire;
|
|
19
19
|
}
|
|
20
|
-
interface
|
|
20
|
+
interface ParcelModule {
|
|
21
21
|
hot: {|
|
|
22
22
|
data: mixed,
|
|
23
23
|
accept(cb: (Function) => void): void,
|
|
@@ -35,7 +35,7 @@ interface ExtensionContext {
|
|
|
35
35
|
getManifest(): {manifest_version: number, ...};
|
|
36
36
|
|};
|
|
37
37
|
}
|
|
38
|
-
declare var module: {bundle:
|
|
38
|
+
declare var module: {bundle: ParcelRequire, ...};
|
|
39
39
|
declare var HMR_HOST: string;
|
|
40
40
|
declare var HMR_PORT: string;
|
|
41
41
|
declare var HMR_ENV_HASH: string;
|
|
@@ -43,13 +43,13 @@ declare var HMR_SECURE: boolean;
|
|
|
43
43
|
declare var HMR_USE_SSE: boolean;
|
|
44
44
|
declare var chrome: ExtensionContext;
|
|
45
45
|
declare var browser: ExtensionContext;
|
|
46
|
-
declare var
|
|
47
|
-
declare var
|
|
46
|
+
declare var __parcel__import__: (string) => Promise<void>;
|
|
47
|
+
declare var __parcel__importScripts__: (string) => Promise<void>;
|
|
48
48
|
declare var globalThis: typeof self;
|
|
49
49
|
declare var ServiceWorkerGlobalScope: Object;
|
|
50
50
|
*/
|
|
51
51
|
|
|
52
|
-
var OVERLAY_ID = '
|
|
52
|
+
var OVERLAY_ID = '__parcel__error__overlay__';
|
|
53
53
|
|
|
54
54
|
var OldModule = module.bundle.Module;
|
|
55
55
|
|
|
@@ -72,8 +72,8 @@ module.bundle.Module = Module;
|
|
|
72
72
|
module.bundle.hotData = {};
|
|
73
73
|
|
|
74
74
|
var checkedAssets /*: {|[string]: boolean|} */,
|
|
75
|
-
assetsToDispose /*: Array<[
|
|
76
|
-
assetsToAccept /*: Array<[
|
|
75
|
+
assetsToDispose /*: Array<[ParcelRequire, string]> */,
|
|
76
|
+
assetsToAccept /*: Array<[ParcelRequire, string]> */;
|
|
77
77
|
|
|
78
78
|
function getHostname() {
|
|
79
79
|
return (
|
|
@@ -88,10 +88,7 @@ function getPort() {
|
|
|
88
88
|
|
|
89
89
|
// eslint-disable-next-line no-redeclare
|
|
90
90
|
var parent = module.bundle.parent;
|
|
91
|
-
if (
|
|
92
|
-
(!parent || !parent.isAtlaspackRequire) &&
|
|
93
|
-
typeof WebSocket !== 'undefined'
|
|
94
|
-
) {
|
|
91
|
+
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
|
95
92
|
var hostname = getHostname();
|
|
96
93
|
var port = getPort();
|
|
97
94
|
var protocol =
|
|
@@ -103,7 +100,7 @@ if (
|
|
|
103
100
|
|
|
104
101
|
var ws;
|
|
105
102
|
if (HMR_USE_SSE) {
|
|
106
|
-
ws = new EventSource('/
|
|
103
|
+
ws = new EventSource('/__parcel_hmr');
|
|
107
104
|
} else {
|
|
108
105
|
try {
|
|
109
106
|
ws = new WebSocket(
|
|
@@ -169,7 +166,7 @@ if (
|
|
|
169
166
|
typeof window !== 'undefined' &&
|
|
170
167
|
typeof CustomEvent !== 'undefined'
|
|
171
168
|
) {
|
|
172
|
-
window.dispatchEvent(new CustomEvent('
|
|
169
|
+
window.dispatchEvent(new CustomEvent('parcelhmraccept'));
|
|
173
170
|
}
|
|
174
171
|
|
|
175
172
|
await hmrApplyUpdates(assets);
|
|
@@ -199,14 +196,14 @@ if (
|
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
if (data.type === 'error') {
|
|
202
|
-
// Log
|
|
199
|
+
// Log parcel errors to console
|
|
203
200
|
for (let ansiDiagnostic of data.diagnostics.ansi) {
|
|
204
201
|
let stack = ansiDiagnostic.codeframe
|
|
205
202
|
? ansiDiagnostic.codeframe
|
|
206
203
|
: ansiDiagnostic.stack;
|
|
207
204
|
|
|
208
205
|
console.error(
|
|
209
|
-
'🚨 [
|
|
206
|
+
'🚨 [parcel]: ' +
|
|
210
207
|
ansiDiagnostic.message +
|
|
211
208
|
'\n' +
|
|
212
209
|
stack +
|
|
@@ -232,7 +229,7 @@ if (
|
|
|
232
229
|
};
|
|
233
230
|
ws.onclose = function (e) {
|
|
234
231
|
if (process.env.ATLASPACK_BUILD_ENV !== 'test') {
|
|
235
|
-
console.warn('[
|
|
232
|
+
console.warn('[parcel] 🚨 Connection to the HMR server was lost');
|
|
236
233
|
}
|
|
237
234
|
};
|
|
238
235
|
}
|
|
@@ -242,7 +239,7 @@ function removeErrorOverlay() {
|
|
|
242
239
|
var overlay = document.getElementById(OVERLAY_ID);
|
|
243
240
|
if (overlay) {
|
|
244
241
|
overlay.remove();
|
|
245
|
-
console.log('[
|
|
242
|
+
console.log('[parcel] ✨ Error resolved');
|
|
246
243
|
}
|
|
247
244
|
}
|
|
248
245
|
|
|
@@ -257,7 +254,7 @@ function createErrorOverlay(diagnostics) {
|
|
|
257
254
|
let stack = diagnostic.frames.length
|
|
258
255
|
? diagnostic.frames.reduce((p, frame) => {
|
|
259
256
|
return `${p}
|
|
260
|
-
<a href="/
|
|
257
|
+
<a href="/__parcel_launch_editor?file=${encodeURIComponent(
|
|
261
258
|
frame.location,
|
|
262
259
|
)}" style="text-decoration: underline; color: #888" onclick="fetch(this.href); return false">${
|
|
263
260
|
frame.location
|
|
@@ -299,7 +296,7 @@ function fullReload() {
|
|
|
299
296
|
}
|
|
300
297
|
}
|
|
301
298
|
|
|
302
|
-
function getParents(bundle, id) /*: Array<[
|
|
299
|
+
function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ {
|
|
303
300
|
var modules = bundle.modules;
|
|
304
301
|
if (!modules) {
|
|
305
302
|
return [];
|
|
@@ -394,11 +391,11 @@ function hmrDownload(asset) {
|
|
|
394
391
|
} else if (typeof importScripts === 'function') {
|
|
395
392
|
// Worker scripts
|
|
396
393
|
if (asset.outputFormat === 'esmodule') {
|
|
397
|
-
return
|
|
394
|
+
return __parcel__import__(asset.url + '?t=' + Date.now());
|
|
398
395
|
} else {
|
|
399
396
|
return new Promise((resolve, reject) => {
|
|
400
397
|
try {
|
|
401
|
-
|
|
398
|
+
__parcel__importScripts__(asset.url + '?t=' + Date.now());
|
|
402
399
|
resolve();
|
|
403
400
|
} catch (err) {
|
|
404
401
|
reject(err);
|
|
@@ -410,7 +407,7 @@ function hmrDownload(asset) {
|
|
|
410
407
|
}
|
|
411
408
|
|
|
412
409
|
async function hmrApplyUpdates(assets) {
|
|
413
|
-
global.
|
|
410
|
+
global.parcelHotUpdate = Object.create(null);
|
|
414
411
|
|
|
415
412
|
let scriptsToRemove;
|
|
416
413
|
try {
|
|
@@ -445,7 +442,7 @@ async function hmrApplyUpdates(assets) {
|
|
|
445
442
|
hmrApply(module.bundle.root, asset);
|
|
446
443
|
});
|
|
447
444
|
} finally {
|
|
448
|
-
delete global.
|
|
445
|
+
delete global.parcelHotUpdate;
|
|
449
446
|
|
|
450
447
|
if (scriptsToRemove) {
|
|
451
448
|
scriptsToRemove.forEach(script => {
|
|
@@ -457,7 +454,7 @@ async function hmrApplyUpdates(assets) {
|
|
|
457
454
|
}
|
|
458
455
|
}
|
|
459
456
|
|
|
460
|
-
function hmrApply(bundle /*:
|
|
457
|
+
function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
|
|
461
458
|
var modules = bundle.modules;
|
|
462
459
|
if (!modules) {
|
|
463
460
|
return;
|
|
@@ -490,7 +487,7 @@ function hmrApply(bundle /*: AtlaspackRequire */, asset /*: HMRAsset */) {
|
|
|
490
487
|
}
|
|
491
488
|
|
|
492
489
|
// $FlowFixMe
|
|
493
|
-
let fn = global.
|
|
490
|
+
let fn = global.parcelHotUpdate[asset.id];
|
|
494
491
|
modules[asset.id] = [fn, deps];
|
|
495
492
|
} else if (bundle.parent) {
|
|
496
493
|
hmrApply(bundle.parent, asset);
|
|
@@ -529,7 +526,7 @@ function hmrDelete(bundle, id) {
|
|
|
529
526
|
}
|
|
530
527
|
|
|
531
528
|
function hmrAcceptCheck(
|
|
532
|
-
bundle /*:
|
|
529
|
+
bundle /*: ParcelRequire */,
|
|
533
530
|
id /*: string */,
|
|
534
531
|
depsByBundle /*: ?{ [string]: { [string]: string } }*/,
|
|
535
532
|
) {
|
|
@@ -562,7 +559,7 @@ function hmrAcceptCheck(
|
|
|
562
559
|
}
|
|
563
560
|
|
|
564
561
|
function hmrAcceptCheckOne(
|
|
565
|
-
bundle /*:
|
|
562
|
+
bundle /*: ParcelRequire */,
|
|
566
563
|
id /*: string */,
|
|
567
564
|
depsByBundle /*: ?{ [string]: { [string]: string } }*/,
|
|
568
565
|
) {
|
|
@@ -596,7 +593,7 @@ function hmrAcceptCheckOne(
|
|
|
596
593
|
}
|
|
597
594
|
}
|
|
598
595
|
|
|
599
|
-
function hmrDispose(bundle /*:
|
|
596
|
+
function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
|
|
600
597
|
var cached = bundle.cache[id];
|
|
601
598
|
bundle.hotData[id] = {};
|
|
602
599
|
if (cached && cached.hot) {
|
|
@@ -612,7 +609,7 @@ function hmrDispose(bundle /*: AtlaspackRequire */, id /*: string */) {
|
|
|
612
609
|
delete bundle.cache[id];
|
|
613
610
|
}
|
|
614
611
|
|
|
615
|
-
function hmrAccept(bundle /*:
|
|
612
|
+
function hmrAccept(bundle /*: ParcelRequire */, id /*: string */) {
|
|
616
613
|
// Execute the module.
|
|
617
614
|
bundle(id);
|
|
618
615
|
|