@atlaspack/runtime-browser-hmr 2.14.5-canary.9 → 2.14.5-canary.91
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/CHANGELOG.md +74 -0
- package/lib/loaders/hmr-runtime.js +33 -21
- package/package.json +4 -4
- package/src/loaders/hmr-runtime.js +39 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,79 @@
|
|
|
1
1
|
# @atlaspack/runtime-browser-hmr
|
|
2
2
|
|
|
3
|
+
## 2.14.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#633](https://github.com/atlassian-labs/atlaspack/pull/633) [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b) Thanks [@sbhuiyan-atlassian](https://github.com/sbhuiyan-atlassian)! - Ported various HMR changes from Parcel
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @atlaspack/utils@2.15.1
|
|
11
|
+
- @atlaspack/plugin@2.14.13
|
|
12
|
+
|
|
13
|
+
## 2.14.12
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
|
|
18
|
+
- @atlaspack/utils@2.15.0
|
|
19
|
+
- @atlaspack/plugin@2.14.12
|
|
20
|
+
|
|
21
|
+
## 2.14.11
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies []:
|
|
26
|
+
- @atlaspack/utils@2.14.11
|
|
27
|
+
- @atlaspack/plugin@2.14.11
|
|
28
|
+
|
|
29
|
+
## 2.14.10
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies []:
|
|
34
|
+
- @atlaspack/plugin@2.14.10
|
|
35
|
+
- @atlaspack/utils@2.14.10
|
|
36
|
+
|
|
37
|
+
## 2.14.9
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies []:
|
|
42
|
+
- @atlaspack/utils@2.14.9
|
|
43
|
+
- @atlaspack/plugin@2.14.9
|
|
44
|
+
|
|
45
|
+
## 2.14.8
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies []:
|
|
50
|
+
- @atlaspack/utils@2.14.8
|
|
51
|
+
- @atlaspack/plugin@2.14.8
|
|
52
|
+
|
|
53
|
+
## 2.14.7
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies []:
|
|
58
|
+
- @atlaspack/utils@2.14.7
|
|
59
|
+
- @atlaspack/plugin@2.14.7
|
|
60
|
+
|
|
61
|
+
## 2.14.6
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies []:
|
|
66
|
+
- @atlaspack/utils@2.14.6
|
|
67
|
+
- @atlaspack/plugin@2.14.6
|
|
68
|
+
|
|
69
|
+
## 2.14.5
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies []:
|
|
74
|
+
- @atlaspack/utils@2.14.5
|
|
75
|
+
- @atlaspack/plugin@2.14.5
|
|
76
|
+
|
|
3
77
|
## 2.14.4
|
|
4
78
|
|
|
5
79
|
### Patch Changes
|
|
@@ -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<[ParcelRequire, string]> */, assetsToAccept /*: Array<[ParcelRequire, string]> */;
|
|
70
|
+
var checkedAssets /*: {|[string]: boolean|} */, disposedAssets /*: {|[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');
|
|
@@ -111,6 +111,7 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
|
|
111
111
|
// $FlowFixMe
|
|
112
112
|
ws.onmessage = async function (event /*: {data: string, ...} */) {
|
|
113
113
|
checkedAssets = {} /*: {|[string]: boolean|} */;
|
|
114
|
+
disposedAssets = {} /*: {|[string]: boolean|} */;
|
|
114
115
|
assetsToAccept = [];
|
|
115
116
|
assetsToDispose = [];
|
|
116
117
|
var data /*: HMRMessage */ = JSON.parse(event.data);
|
|
@@ -135,19 +136,10 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
|
|
135
136
|
window.dispatchEvent(new CustomEvent('parcelhmraccept'));
|
|
136
137
|
}
|
|
137
138
|
await hmrApplyUpdates(assets);
|
|
138
|
-
|
|
139
|
-
// Dispose all old assets.
|
|
140
|
-
let processedAssets = {} /*: {|[string]: boolean|} */;
|
|
141
|
-
for (let i = 0; i < assetsToDispose.length; i++) {
|
|
142
|
-
let id = assetsToDispose[i][1];
|
|
143
|
-
if (!processedAssets[id]) {
|
|
144
|
-
hmrDispose(assetsToDispose[i][0], id);
|
|
145
|
-
processedAssets[id] = true;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
139
|
+
hmrDisposeQueue();
|
|
148
140
|
|
|
149
141
|
// Run accept callbacks. This will also re-execute other disposed assets in topological order.
|
|
150
|
-
processedAssets = {};
|
|
142
|
+
let processedAssets = {};
|
|
151
143
|
for (let i = 0; i < assetsToAccept.length; i++) {
|
|
152
144
|
let id = assetsToAccept[i][1];
|
|
153
145
|
if (!processedAssets[id]) {
|
|
@@ -385,7 +377,11 @@ function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
|
|
|
385
377
|
// $FlowFixMe
|
|
386
378
|
let fn = global.parcelHotUpdate[asset.id];
|
|
387
379
|
modules[asset.id] = [fn, deps];
|
|
388
|
-
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Always traverse to the parent bundle, even if we already replaced the asset in this bundle.
|
|
383
|
+
// This is required in case modules are duplicated. We need to ensure all instances have the updated code.
|
|
384
|
+
if (bundle.parent) {
|
|
389
385
|
hmrApply(bundle.parent, asset);
|
|
390
386
|
}
|
|
391
387
|
}
|
|
@@ -469,6 +465,17 @@ function hmrAcceptCheckOne(bundle /*: ParcelRequire */, id /*: string */, depsBy
|
|
|
469
465
|
return true;
|
|
470
466
|
}
|
|
471
467
|
}
|
|
468
|
+
function hmrDisposeQueue() {
|
|
469
|
+
// Dispose all old assets.
|
|
470
|
+
for (let i = 0; i < assetsToDispose.length; i++) {
|
|
471
|
+
let id = assetsToDispose[i][1];
|
|
472
|
+
if (!disposedAssets[id]) {
|
|
473
|
+
hmrDispose(assetsToDispose[i][0], id);
|
|
474
|
+
disposedAssets[id] = true;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
assetsToDispose = [];
|
|
478
|
+
}
|
|
472
479
|
function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
|
|
473
480
|
var cached = bundle.cache[id];
|
|
474
481
|
bundle.hotData[id] = {};
|
|
@@ -489,18 +496,23 @@ function hmrAccept(bundle /*: ParcelRequire */, id /*: string */) {
|
|
|
489
496
|
// Run the accept callbacks in the new version of the module.
|
|
490
497
|
var cached = bundle.cache[id];
|
|
491
498
|
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
|
499
|
+
let assetsToAlsoAccept = [];
|
|
492
500
|
cached.hot._acceptCallbacks.forEach(function (cb) {
|
|
493
|
-
|
|
501
|
+
let additionalAssets = cb(function () {
|
|
494
502
|
return getParents(module.bundle.root, id);
|
|
495
503
|
});
|
|
496
|
-
if (
|
|
497
|
-
assetsToAlsoAccept.
|
|
498
|
-
hmrDispose(a[0], a[1]);
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
// $FlowFixMe[method-unbinding]
|
|
502
|
-
assetsToAccept.push.apply(assetsToAccept, assetsToAlsoAccept);
|
|
504
|
+
if (Array.isArray(additionalAssets) && additionalAssets.length) {
|
|
505
|
+
assetsToAlsoAccept.push(...additionalAssets);
|
|
503
506
|
}
|
|
504
507
|
});
|
|
508
|
+
if (assetsToAlsoAccept.length > 0) {
|
|
509
|
+
let handled = assetsToAlsoAccept.every(function (a) {
|
|
510
|
+
return hmrAcceptCheck(a[0], a[1]);
|
|
511
|
+
});
|
|
512
|
+
if (!handled) {
|
|
513
|
+
return fullReload();
|
|
514
|
+
}
|
|
515
|
+
hmrDisposeQueue();
|
|
516
|
+
}
|
|
505
517
|
}
|
|
506
518
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/runtime-browser-hmr",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.91+644b157de",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"node": ">= 16.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
19
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
18
|
+
"@atlaspack/plugin": "2.14.5-canary.91+644b157de",
|
|
19
|
+
"@atlaspack/utils": "2.14.5-canary.91+644b157de"
|
|
20
20
|
},
|
|
21
21
|
"type": "commonjs",
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "644b157dee72a871acc2d0facf0b87b8eea51956"
|
|
23
23
|
}
|
|
@@ -72,6 +72,7 @@ module.bundle.Module = Module;
|
|
|
72
72
|
module.bundle.hotData = {};
|
|
73
73
|
|
|
74
74
|
var checkedAssets /*: {|[string]: boolean|} */,
|
|
75
|
+
disposedAssets /*: {|[string]: boolean|} */,
|
|
75
76
|
assetsToDispose /*: Array<[ParcelRequire, string]> */,
|
|
76
77
|
assetsToAccept /*: Array<[ParcelRequire, string]> */;
|
|
77
78
|
|
|
@@ -134,6 +135,7 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
|
|
134
135
|
// $FlowFixMe
|
|
135
136
|
ws.onmessage = async function (event /*: {data: string, ...} */) {
|
|
136
137
|
checkedAssets = ({} /*: {|[string]: boolean|} */);
|
|
138
|
+
disposedAssets = ({} /*: {|[string]: boolean|} */);
|
|
137
139
|
assetsToAccept = [];
|
|
138
140
|
assetsToDispose = [];
|
|
139
141
|
|
|
@@ -173,19 +175,10 @@ if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
|
|
173
175
|
|
|
174
176
|
await hmrApplyUpdates(assets);
|
|
175
177
|
|
|
176
|
-
|
|
177
|
-
let processedAssets = ({} /*: {|[string]: boolean|} */);
|
|
178
|
-
for (let i = 0; i < assetsToDispose.length; i++) {
|
|
179
|
-
let id = assetsToDispose[i][1];
|
|
180
|
-
|
|
181
|
-
if (!processedAssets[id]) {
|
|
182
|
-
hmrDispose(assetsToDispose[i][0], id);
|
|
183
|
-
processedAssets[id] = true;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
178
|
+
hmrDisposeQueue();
|
|
186
179
|
|
|
187
180
|
// Run accept callbacks. This will also re-execute other disposed assets in topological order.
|
|
188
|
-
processedAssets = {};
|
|
181
|
+
let processedAssets = {};
|
|
189
182
|
for (let i = 0; i < assetsToAccept.length; i++) {
|
|
190
183
|
let id = assetsToAccept[i][1];
|
|
191
184
|
|
|
@@ -493,7 +486,11 @@ function hmrApply(bundle /*: ParcelRequire */, asset /*: HMRAsset */) {
|
|
|
493
486
|
// $FlowFixMe
|
|
494
487
|
let fn = global.parcelHotUpdate[asset.id];
|
|
495
488
|
modules[asset.id] = [fn, deps];
|
|
496
|
-
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// Always traverse to the parent bundle, even if we already replaced the asset in this bundle.
|
|
492
|
+
// This is required in case modules are duplicated. We need to ensure all instances have the updated code.
|
|
493
|
+
if (bundle.parent) {
|
|
497
494
|
hmrApply(bundle.parent, asset);
|
|
498
495
|
}
|
|
499
496
|
}
|
|
@@ -597,6 +594,20 @@ function hmrAcceptCheckOne(
|
|
|
597
594
|
}
|
|
598
595
|
}
|
|
599
596
|
|
|
597
|
+
function hmrDisposeQueue() {
|
|
598
|
+
// Dispose all old assets.
|
|
599
|
+
for (let i = 0; i < assetsToDispose.length; i++) {
|
|
600
|
+
let id = assetsToDispose[i][1];
|
|
601
|
+
|
|
602
|
+
if (!disposedAssets[id]) {
|
|
603
|
+
hmrDispose(assetsToDispose[i][0], id);
|
|
604
|
+
disposedAssets[id] = true;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
assetsToDispose = [];
|
|
609
|
+
}
|
|
610
|
+
|
|
600
611
|
function hmrDispose(bundle /*: ParcelRequire */, id /*: string */) {
|
|
601
612
|
var cached = bundle.cache[id];
|
|
602
613
|
bundle.hotData[id] = {};
|
|
@@ -620,18 +631,26 @@ function hmrAccept(bundle /*: ParcelRequire */, id /*: string */) {
|
|
|
620
631
|
// Run the accept callbacks in the new version of the module.
|
|
621
632
|
var cached = bundle.cache[id];
|
|
622
633
|
if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
|
|
634
|
+
let assetsToAlsoAccept = [];
|
|
623
635
|
cached.hot._acceptCallbacks.forEach(function (cb) {
|
|
624
|
-
|
|
636
|
+
let additionalAssets = cb(function () {
|
|
625
637
|
return getParents(module.bundle.root, id);
|
|
626
638
|
});
|
|
627
|
-
if (
|
|
628
|
-
assetsToAlsoAccept.
|
|
629
|
-
hmrDispose(a[0], a[1]);
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
// $FlowFixMe[method-unbinding]
|
|
633
|
-
assetsToAccept.push.apply(assetsToAccept, assetsToAlsoAccept);
|
|
639
|
+
if (Array.isArray(additionalAssets) && additionalAssets.length) {
|
|
640
|
+
assetsToAlsoAccept.push(...additionalAssets);
|
|
634
641
|
}
|
|
635
642
|
});
|
|
643
|
+
|
|
644
|
+
if (assetsToAlsoAccept.length > 0) {
|
|
645
|
+
let handled = assetsToAlsoAccept.every(function (a) {
|
|
646
|
+
return hmrAcceptCheck(a[0], a[1]);
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
if (!handled) {
|
|
650
|
+
return fullReload();
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
hmrDisposeQueue();
|
|
654
|
+
}
|
|
636
655
|
}
|
|
637
656
|
}
|