html-bundle 6.0.13 → 6.0.15
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 +2 -2
- package/package.json +49 -49
- package/src/bundle.mts +6 -4
- package/src/utils.mts +3 -3
package/dist/bundle.mjs
CHANGED
|
@@ -44,8 +44,8 @@ async function build(err, files, firstRun = true) {
|
|
|
44
44
|
}
|
|
45
45
|
if (isHMR && firstRun) {
|
|
46
46
|
fastify = await createDefaultServer(isSecure);
|
|
47
|
-
fastify.listen(bundleConfig.port);
|
|
48
|
-
console.log(`💻 Sever listening on
|
|
47
|
+
await fastify.listen({ port: bundleConfig.port });
|
|
48
|
+
console.log(`💻 Sever listening on http${isSecure ? "s" : ""}://localhost:5000.`);
|
|
49
49
|
}
|
|
50
50
|
for (const file of files) {
|
|
51
51
|
await createDir(file);
|
package/package.json
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "html-bundle",
|
|
3
|
-
"version": "6.0.
|
|
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": "^
|
|
23
|
-
"@types/html-minifier-terser": "^
|
|
24
|
-
"@types/parse5": "^
|
|
25
|
-
"@types/postcss-load-config": "^3.0.1",
|
|
26
|
-
"typescript": "^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": "^
|
|
35
|
-
"@web/parse5-utils": "^1.3.0",
|
|
36
|
-
"await-spawn": "^4.0.2",
|
|
37
|
-
"chokidar": "^3.5.3",
|
|
38
|
-
"critters": "^0.0.16",
|
|
39
|
-
"cssnano": "^5.1.
|
|
40
|
-
"esbuild": "^0.
|
|
41
|
-
"fastify": "^
|
|
42
|
-
"glob": "^8.0
|
|
43
|
-
"html-minifier-terser": "^
|
|
44
|
-
"hydro-js": "^1.5.13",
|
|
45
|
-
"parse5": "^7.
|
|
46
|
-
"postcss": "^8.4.
|
|
47
|
-
"postcss-load-config": "^
|
|
48
|
-
}
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "html-bundle",
|
|
3
|
+
"version": "6.0.15",
|
|
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.0.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": "^4.9.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.6.1",
|
|
35
|
+
"@web/parse5-utils": "^1.3.0",
|
|
36
|
+
"await-spawn": "^4.0.2",
|
|
37
|
+
"chokidar": "^3.5.3",
|
|
38
|
+
"critters": "^0.0.16",
|
|
39
|
+
"cssnano": "^5.1.14",
|
|
40
|
+
"esbuild": "^0.17.3",
|
|
41
|
+
"fastify": "^4.11.0",
|
|
42
|
+
"glob": "^8.1.0",
|
|
43
|
+
"html-minifier-terser": "^7.1.0",
|
|
44
|
+
"hydro-js": "^1.5.13",
|
|
45
|
+
"parse5": "^7.1.2",
|
|
46
|
+
"postcss": "^8.4.21",
|
|
47
|
+
"postcss-load-config": "^4.0.1"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/bundle.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import type { TextNode } from "@web/parse5-utils";
|
|
3
|
+
import type { Node, TextNode } from "@web/parse5-utils";
|
|
4
4
|
import type { AcceptedPlugin } from "postcss";
|
|
5
5
|
import { performance } from "perf_hooks";
|
|
6
6
|
import { readFile, rm, writeFile, readdir, lstat } from "fs/promises";
|
|
@@ -63,8 +63,10 @@ async function build(err: any, files: string[], firstRun = true) {
|
|
|
63
63
|
|
|
64
64
|
if (isHMR && firstRun) {
|
|
65
65
|
fastify = await createDefaultServer(isSecure);
|
|
66
|
-
fastify.listen(bundleConfig.port);
|
|
67
|
-
console.log(
|
|
66
|
+
await fastify.listen({ port: bundleConfig.port });
|
|
67
|
+
console.log(
|
|
68
|
+
`💻 Sever listening on http${isSecure ? "s" : ""}://localhost:5000.`
|
|
69
|
+
);
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
for (const file of files) {
|
|
@@ -288,7 +290,7 @@ async function writeInlineScripts(file: string) {
|
|
|
288
290
|
}
|
|
289
291
|
htmlFilesCache.set(file, [fileText, DOM]);
|
|
290
292
|
|
|
291
|
-
const scripts = findElements(DOM, (e) => getTagName(e) === "script");
|
|
293
|
+
const scripts = findElements(DOM as Node, (e) => getTagName(e) === "script");
|
|
292
294
|
for (let index = 0; index < scripts.length; index++) {
|
|
293
295
|
const script = scripts[index];
|
|
294
296
|
const scriptTextNode = script.childNodes[0] as TextNode;
|
package/src/utils.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ParentNode } from "@web/parse5-utils";
|
|
1
|
+
import type { Node, ParentNode } from "@web/parse5-utils";
|
|
2
2
|
import type { FastifyServerOptions } from "fastify";
|
|
3
3
|
import { copyFile, mkdir, readFile } from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
@@ -124,7 +124,7 @@ export function addHMRCode(
|
|
|
124
124
|
let DOM;
|
|
125
125
|
if (html.includes("<!DOCTYPE html>") || html.includes("<html")) {
|
|
126
126
|
DOM = ast || parse(html);
|
|
127
|
-
const headNode = findElement(DOM, (e) => getTagName(e) === "head");
|
|
127
|
+
const headNode = findElement(DOM as Node, (e) => getTagName(e) === "head");
|
|
128
128
|
appendChild(headNode, script);
|
|
129
129
|
} else {
|
|
130
130
|
DOM = ast || parseFragment(html);
|
|
@@ -136,7 +136,7 @@ export function addHMRCode(
|
|
|
136
136
|
node.attrs?.push({ name: "data-hmr", value: htmlIdMap.get(file) })
|
|
137
137
|
);
|
|
138
138
|
|
|
139
|
-
return serialize(DOM as
|
|
139
|
+
return serialize(DOM as any);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
function randomText() {
|