html-bundle 6.0.19 → 6.0.20
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/dist/utils.mjs +4 -0
- package/package.json +2 -2
- package/src/utils.mts +4 -0
package/dist/utils.mjs
CHANGED
|
@@ -118,6 +118,7 @@ function getHMRCode(file, id, src) {
|
|
|
118
118
|
}, 1000);
|
|
119
119
|
});
|
|
120
120
|
window.eventsource${id}.addEventListener("message", ({ data }) => {
|
|
121
|
+
window.lastScroll = window.scrollY;
|
|
121
122
|
const dataObj = JSON.parse(data);
|
|
122
123
|
const file = "${file}";
|
|
123
124
|
|
|
@@ -134,6 +135,9 @@ function getHMRCode(file, id, src) {
|
|
|
134
135
|
if (dataObj.html.startsWith('<!DOCTYPE html>') || dataObj.html.startsWith('<html')) {
|
|
135
136
|
document.head.remove(); // Don't try to diff the head – just re-run the scripts
|
|
136
137
|
render(newHTML, document.documentElement, false);
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
window.scrollTo(0, window.lastScroll);
|
|
140
|
+
}, 50);
|
|
137
141
|
} else {
|
|
138
142
|
const hmrID = "${id}";
|
|
139
143
|
const hmrElems = Array.from(newHTML.childNodes);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-bundle",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.20",
|
|
4
4
|
"description": "A very simple bundler for HTML SFC",
|
|
5
5
|
"bin": "./dist/bundle.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"chokidar": "^3.5.3",
|
|
38
38
|
"critters": "^0.0.20",
|
|
39
39
|
"cssnano": "^6.0.2",
|
|
40
|
-
"esbuild": "^0.19.
|
|
40
|
+
"esbuild": "^0.19.10",
|
|
41
41
|
"fastify": "^4.25.1",
|
|
42
42
|
"glob": "^10.3.10",
|
|
43
43
|
"html-minifier-terser": "^7.2.0",
|
package/src/utils.mts
CHANGED
|
@@ -155,6 +155,7 @@ function getHMRCode(file: string, id: string, src: string) {
|
|
|
155
155
|
}, 1000);
|
|
156
156
|
});
|
|
157
157
|
window.eventsource${id}.addEventListener("message", ({ data }) => {
|
|
158
|
+
window.lastScroll = window.scrollY;
|
|
158
159
|
const dataObj = JSON.parse(data);
|
|
159
160
|
const file = "${file}";
|
|
160
161
|
|
|
@@ -171,6 +172,9 @@ function getHMRCode(file: string, id: string, src: string) {
|
|
|
171
172
|
if (dataObj.html.startsWith('<!DOCTYPE html>') || dataObj.html.startsWith('<html')) {
|
|
172
173
|
document.head.remove(); // Don't try to diff the head – just re-run the scripts
|
|
173
174
|
render(newHTML, document.documentElement, false);
|
|
175
|
+
setTimeout(() => {
|
|
176
|
+
window.scrollTo(0, window.lastScroll);
|
|
177
|
+
}, 50);
|
|
174
178
|
} else {
|
|
175
179
|
const hmrID = "${id}";
|
|
176
180
|
const hmrElems = Array.from(newHTML.childNodes);
|