html-bundle 6.0.18 → 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/bundle.mjs CHANGED
@@ -40,8 +40,8 @@ if (bundleConfig.deletePrev) {
40
40
  async function build(files, firstRun = true) {
41
41
  if (isHMR && firstRun) {
42
42
  fastify = await createDefaultServer(isSecure);
43
- await fastify.listen({ port: bundleConfig.port });
44
- console.log(`💻 Sever listening on http${isSecure ? "s" : ""}://localhost:${bundleConfig.port}.`);
43
+ await fastify.listen({ port: bundleConfig.port, host: "::" });
44
+ console.log(`💻 Server listening on http${isSecure ? "s" : ""}://localhost:${bundleConfig.port}. and is shared in the local network.`);
45
45
  }
46
46
  for (const file of files) {
47
47
  await createDir(file);
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,49 +1,49 @@
1
- {
2
- "name": "html-bundle",
3
- "version": "6.0.18",
4
- "description": "A very simple bundler for HTML SFC",
5
- "bin": "./dist/bundle.mjs",
6
- "scripts": {
7
- "start": "tsc",
8
- "update": "npx npm-check-updates -u && npx typesync && npm i && npm outdated"
9
- },
10
- "keywords": [
11
- "bundler",
12
- "SFC",
13
- "HTML",
14
- "TypeScript",
15
- "esbuild",
16
- "hydro-js"
17
- ],
18
- "author": "Fabian Krutsch <f.krutsch@gmx.de> (https://krutsch.netlify.app/)",
19
- "license": "MIT",
20
- "devDependencies": {
21
- "@types/cssnano": "^5.0.0",
22
- "@types/glob": "^8.1.0",
23
- "@types/html-minifier-terser": "^7.0.0",
24
- "@types/parse5": "^7.0.0",
25
- "@types/postcss-load-config": "^3.0.1",
26
- "typescript": "^5.0.4"
27
- },
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/Krutsch/html-bundle.git"
31
- },
32
- "bugs": "https://github.com/Krutsch/html-bundle/issues",
33
- "dependencies": {
34
- "@fastify/static": "^6.10.1",
35
- "@web/parse5-utils": "^2.0.0",
36
- "await-spawn": "^4.0.2",
37
- "chokidar": "^3.5.3",
38
- "critters": "^0.0.16",
39
- "cssnano": "^6.0.0",
40
- "esbuild": "^0.17.18",
41
- "fastify": "^4.17.0",
42
- "glob": "^10.2.2",
43
- "html-minifier-terser": "^7.2.0",
44
- "hydro-js": "^1.5.14",
45
- "parse5": "^7.1.2",
46
- "postcss": "^8.4.23",
47
- "postcss-load-config": "^4.0.1"
48
- }
49
- }
1
+ {
2
+ "name": "html-bundle",
3
+ "version": "6.0.20",
4
+ "description": "A very simple bundler for HTML SFC",
5
+ "bin": "./dist/bundle.mjs",
6
+ "scripts": {
7
+ "start": "tsc",
8
+ "update": "npx npm-check-updates -u && npx typesync && npm i && npm outdated"
9
+ },
10
+ "keywords": [
11
+ "bundler",
12
+ "SFC",
13
+ "HTML",
14
+ "TypeScript",
15
+ "esbuild",
16
+ "hydro-js"
17
+ ],
18
+ "author": "Fabian Krutsch <f.krutsch@gmx.de> (https://krutsch.netlify.app/)",
19
+ "license": "MIT",
20
+ "devDependencies": {
21
+ "@types/cssnano": "^5.0.0",
22
+ "@types/glob": "^8.1.0",
23
+ "@types/html-minifier-terser": "^7.0.2",
24
+ "@types/parse5": "^7.0.0",
25
+ "@types/postcss-load-config": "^3.0.1",
26
+ "typescript": "^5.3.3"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/Krutsch/html-bundle.git"
31
+ },
32
+ "bugs": "https://github.com/Krutsch/html-bundle/issues",
33
+ "dependencies": {
34
+ "@fastify/static": "^6.12.0",
35
+ "@web/parse5-utils": "^2.1.0",
36
+ "await-spawn": "^4.0.2",
37
+ "chokidar": "^3.5.3",
38
+ "critters": "^0.0.20",
39
+ "cssnano": "^6.0.2",
40
+ "esbuild": "^0.19.10",
41
+ "fastify": "^4.25.1",
42
+ "glob": "^10.3.10",
43
+ "html-minifier-terser": "^7.2.0",
44
+ "hydro-js": "^1.5.14",
45
+ "parse5": "^7.1.2",
46
+ "postcss": "^8.4.32",
47
+ "postcss-load-config": "^5.0.2"
48
+ }
49
+ }
package/src/bundle.mts CHANGED
@@ -57,11 +57,11 @@ if (bundleConfig.deletePrev) {
57
57
  async function build(files: string[], firstRun = true) {
58
58
  if (isHMR && firstRun) {
59
59
  fastify = await createDefaultServer(isSecure);
60
- await fastify.listen({ port: bundleConfig.port });
60
+ await fastify.listen({ port: bundleConfig.port, host: "::" });
61
61
  console.log(
62
- `💻 Sever listening on http${isSecure ? "s" : ""}://localhost:${
62
+ `💻 Server listening on http${isSecure ? "s" : ""}://localhost:${
63
63
  bundleConfig.port
64
- }.`
64
+ }. and is shared in the local network.`
65
65
  );
66
66
  }
67
67
 
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);
package/tsconfig.json CHANGED
@@ -9,8 +9,7 @@
9
9
  "skipLibCheck": true,
10
10
  "moduleResolution": "node",
11
11
  "esModuleInterop": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "typeRoots": ["node_modules/@types"]
12
+ "forceConsistentCasingInFileNames": true
14
13
  },
15
14
  "include": ["src", "types"]
16
15
  }