html-bundle 6.0.14 → 6.0.16
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 -3
- package/package.json +13 -13
- package/src/bundle.mts +6 -5
- 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);
|
|
@@ -189,7 +189,6 @@ async function minifyCode() {
|
|
|
189
189
|
entryPoints: Array.from(inlineFiles),
|
|
190
190
|
charset: "utf8",
|
|
191
191
|
format: "esm",
|
|
192
|
-
incremental: isHMR,
|
|
193
192
|
sourcemap: isHMR,
|
|
194
193
|
splitting: true,
|
|
195
194
|
define: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-bundle",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.16",
|
|
4
4
|
"description": "A very simple bundler for HTML SFC",
|
|
5
5
|
"bin": "./dist/bundle.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/cssnano": "^5.0.0",
|
|
22
|
-
"@types/glob": "^
|
|
23
|
-
"@types/html-minifier-terser": "^
|
|
24
|
-
"@types/parse5": "^
|
|
22
|
+
"@types/glob": "^8.0.0",
|
|
23
|
+
"@types/html-minifier-terser": "^7.0.0",
|
|
24
|
+
"@types/parse5": "^7.0.0",
|
|
25
25
|
"@types/postcss-load-config": "^3.0.1",
|
|
26
|
-
"typescript": "^4.
|
|
26
|
+
"typescript": "^4.9.4"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
},
|
|
32
32
|
"bugs": "https://github.com/Krutsch/html-bundle/issues",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@fastify/static": "^
|
|
34
|
+
"@fastify/static": "^6.6.1",
|
|
35
35
|
"@web/parse5-utils": "^1.3.0",
|
|
36
36
|
"await-spawn": "^4.0.2",
|
|
37
37
|
"chokidar": "^3.5.3",
|
|
38
38
|
"critters": "^0.0.16",
|
|
39
|
-
"cssnano": "^5.1.
|
|
40
|
-
"esbuild": "^0.
|
|
41
|
-
"fastify": "^
|
|
42
|
-
"glob": "^8.0
|
|
43
|
-
"html-minifier-terser": "^
|
|
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
44
|
"hydro-js": "^1.5.13",
|
|
45
|
-
"parse5": "^7.
|
|
46
|
-
"postcss": "^8.4.
|
|
45
|
+
"parse5": "^7.1.2",
|
|
46
|
+
"postcss": "^8.4.21",
|
|
47
47
|
"postcss-load-config": "^4.0.1"
|
|
48
48
|
}
|
|
49
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) {
|
|
@@ -228,7 +230,6 @@ async function minifyCode(): Promise<unknown> {
|
|
|
228
230
|
entryPoints: Array.from(inlineFiles),
|
|
229
231
|
charset: "utf8",
|
|
230
232
|
format: "esm",
|
|
231
|
-
incremental: isHMR,
|
|
232
233
|
sourcemap: isHMR,
|
|
233
234
|
splitting: true,
|
|
234
235
|
define: {
|
|
@@ -288,7 +289,7 @@ async function writeInlineScripts(file: string) {
|
|
|
288
289
|
}
|
|
289
290
|
htmlFilesCache.set(file, [fileText, DOM]);
|
|
290
291
|
|
|
291
|
-
const scripts = findElements(DOM, (e) => getTagName(e) === "script");
|
|
292
|
+
const scripts = findElements(DOM as Node, (e) => getTagName(e) === "script");
|
|
292
293
|
for (let index = 0; index < scripts.length; index++) {
|
|
293
294
|
const script = scripts[index];
|
|
294
295
|
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() {
|