html-bundle 6.1.4 → 6.1.5
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 +7 -6
- package/dist/utils.mjs +5 -2
- package/package.json +50 -50
- package/src/bundle.mts +11 -8
- package/src/config.d.ts +3 -0
- package/src/utils.mts +5 -2
package/dist/bundle.mjs
CHANGED
|
@@ -80,13 +80,14 @@ async function build(files, firstRun = true) {
|
|
|
80
80
|
console.log(`🚀 Build finished in ${(performance.now() - timer).toFixed(2)}ms ✨`);
|
|
81
81
|
if (isHMR && firstRun) {
|
|
82
82
|
fastify = await createDefaultServer(isSecure);
|
|
83
|
-
await fastify.listen({ port: bundleConfig.port, host:
|
|
84
|
-
console.log(`💻 Server listening on http${isSecure ? "s" : ""}
|
|
83
|
+
await fastify.listen({ port: bundleConfig.port, host: bundleConfig.host });
|
|
84
|
+
console.log(`💻 Server listening on http${isSecure ? "s" : ""}://${bundleConfig.host === "::" ? "localhost" : bundleConfig.host}:${bundleConfig.port} and is shared in the local network.`);
|
|
85
85
|
console.log(`⌛ Waiting for file changes ...`);
|
|
86
|
+
const chokidarOptions = { awaitWriteFinish: false };
|
|
86
87
|
if (postcssFile) {
|
|
87
|
-
const postCSSWatcher = watch(postcssFile);
|
|
88
|
-
const tailwindCSSWatcher = watch(postcssFile.replace("postcss", "tailwind")); // Assuming that the file ext is the same
|
|
89
|
-
const tsConfigWatcher = watch(postcssFile.split("\\").slice(0, -1).join("\\") + "\\tsconfig.json");
|
|
88
|
+
const postCSSWatcher = watch(postcssFile, chokidarOptions);
|
|
89
|
+
const tailwindCSSWatcher = watch(postcssFile.replace("postcss", "tailwind"), chokidarOptions); // Assuming that the file ext is the same
|
|
90
|
+
const tsConfigWatcher = watch(postcssFile.split("\\").slice(0, -1).join("\\") + "\\tsconfig.json", chokidarOptions);
|
|
90
91
|
const cssFiles = files.filter((file) => file.endsWith(".css"));
|
|
91
92
|
postCSSWatcher.on("change", async () => await rebuildCSS(cssFiles, "postcss"));
|
|
92
93
|
tailwindCSSWatcher.on("change", async () => await rebuildCSS(cssFiles, "tailwind"));
|
|
@@ -95,7 +96,7 @@ async function build(files, firstRun = true) {
|
|
|
95
96
|
await build(files, false);
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
|
-
const watcher = watch(bundleConfig.src);
|
|
99
|
+
const watcher = watch(bundleConfig.src, chokidarOptions);
|
|
99
100
|
watcher.on("add", async (file) => {
|
|
100
101
|
file = String.raw `${file}`.replace(/\\/g, "/"); // glob and chokidar diff
|
|
101
102
|
if (files.includes(file) || INLINE_BUNDLE_FILE.test(file)) {
|
package/dist/utils.mjs
CHANGED
|
@@ -25,8 +25,8 @@ export async function createDefaultServer(isSecure) {
|
|
|
25
25
|
? {
|
|
26
26
|
http2: true,
|
|
27
27
|
https: {
|
|
28
|
-
key:
|
|
29
|
-
cert:
|
|
28
|
+
key: bundleConfig.key,
|
|
29
|
+
cert: bundleConfig.cert,
|
|
30
30
|
},
|
|
31
31
|
}
|
|
32
32
|
: void 0);
|
|
@@ -77,6 +77,9 @@ async function getBundleConfig() {
|
|
|
77
77
|
hmr: false,
|
|
78
78
|
secure: false,
|
|
79
79
|
handler: "",
|
|
80
|
+
host: "::",
|
|
81
|
+
key: await readFile(path.join(process.cwd(), "localhost-key.pem")),
|
|
82
|
+
cert: await readFile(path.join(process.cwd(), "localhost.pem")),
|
|
80
83
|
};
|
|
81
84
|
try {
|
|
82
85
|
const cfgPath = path.resolve(process.cwd(), "bundle.config.js");
|
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "html-bundle",
|
|
3
|
-
"version": "6.1.
|
|
4
|
-
"description": "A very simple bundler for HTML SFC",
|
|
5
|
-
"bin": "./dist/bundle.mjs",
|
|
6
|
-
"types": "./src/config.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "tsc",
|
|
9
|
-
"update": "npx npm-check-updates -u && npx typesync && npm i && npm outdated"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [
|
|
12
|
-
"bundler",
|
|
13
|
-
"SFC",
|
|
14
|
-
"HTML",
|
|
15
|
-
"TypeScript",
|
|
16
|
-
"esbuild",
|
|
17
|
-
"hydro-js"
|
|
18
|
-
],
|
|
19
|
-
"author": "Fabian Klingenberg <klingenberg.fabian@gmx.de> (https://klingenberg.netlify.app/)",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"devDependencies": {
|
|
22
|
-
"@types/cssnano": "^5.1.0",
|
|
23
|
-
"@types/glob": "^8.1.0",
|
|
24
|
-
"@types/html-minifier-terser": "^7.0.2",
|
|
25
|
-
"@types/parse5": "^7.0.0",
|
|
26
|
-
"@types/postcss-load-config": "^3.0.1",
|
|
27
|
-
"typescript": "^5.
|
|
28
|
-
},
|
|
29
|
-
"repository": {
|
|
30
|
-
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/Krutsch/html-bundle.git"
|
|
32
|
-
},
|
|
33
|
-
"bugs": "https://github.com/Krutsch/html-bundle/issues",
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@fastify/static": "^
|
|
36
|
-
"@web/parse5-utils": "^2.1.0",
|
|
37
|
-
"await-spawn": "^4.0.2",
|
|
38
|
-
"chokidar": "^
|
|
39
|
-
"critters": "^0.0.24",
|
|
40
|
-
"cssnano": "^7.0.
|
|
41
|
-
"esbuild": "^0.23.1",
|
|
42
|
-
"fastify": "^
|
|
43
|
-
"glob": "^11.0.0",
|
|
44
|
-
"html-minifier-terser": "^7.2.0",
|
|
45
|
-
"hydro-js": "^1.5.19",
|
|
46
|
-
"parse5": "^7.1.2",
|
|
47
|
-
"postcss": "^8.4.
|
|
48
|
-
"postcss-load-config": "^6.0.1"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "html-bundle",
|
|
3
|
+
"version": "6.1.5",
|
|
4
|
+
"description": "A very simple bundler for HTML SFC",
|
|
5
|
+
"bin": "./dist/bundle.mjs",
|
|
6
|
+
"types": "./src/config.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "tsc",
|
|
9
|
+
"update": "npx npm-check-updates -u && npx typesync && npm i && npm outdated"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"bundler",
|
|
13
|
+
"SFC",
|
|
14
|
+
"HTML",
|
|
15
|
+
"TypeScript",
|
|
16
|
+
"esbuild",
|
|
17
|
+
"hydro-js"
|
|
18
|
+
],
|
|
19
|
+
"author": "Fabian Klingenberg <klingenberg.fabian@gmx.de> (https://klingenberg.netlify.app/)",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/cssnano": "^5.1.0",
|
|
23
|
+
"@types/glob": "^8.1.0",
|
|
24
|
+
"@types/html-minifier-terser": "^7.0.2",
|
|
25
|
+
"@types/parse5": "^7.0.0",
|
|
26
|
+
"@types/postcss-load-config": "^3.0.1",
|
|
27
|
+
"typescript": "^5.6.2"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/Krutsch/html-bundle.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": "https://github.com/Krutsch/html-bundle/issues",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@fastify/static": "^8.0.0",
|
|
36
|
+
"@web/parse5-utils": "^2.1.0",
|
|
37
|
+
"await-spawn": "^4.0.2",
|
|
38
|
+
"chokidar": "^4.0.0",
|
|
39
|
+
"critters": "^0.0.24",
|
|
40
|
+
"cssnano": "^7.0.6",
|
|
41
|
+
"esbuild": "^0.23.1",
|
|
42
|
+
"fastify": "^5.0.0",
|
|
43
|
+
"glob": "^11.0.0",
|
|
44
|
+
"html-minifier-terser": "^7.2.0",
|
|
45
|
+
"hydro-js": "^1.5.19",
|
|
46
|
+
"parse5": "^7.1.2",
|
|
47
|
+
"postcss": "^8.4.47",
|
|
48
|
+
"postcss-load-config": "^6.0.1"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/bundle.mts
CHANGED
|
@@ -97,22 +97,25 @@ async function build(files: string[], firstRun = true) {
|
|
|
97
97
|
|
|
98
98
|
if (isHMR && firstRun) {
|
|
99
99
|
fastify = await createDefaultServer(isSecure);
|
|
100
|
-
await fastify.listen({ port: bundleConfig.port, host:
|
|
100
|
+
await fastify.listen({ port: bundleConfig.port, host: bundleConfig.host });
|
|
101
101
|
console.log(
|
|
102
|
-
`💻 Server listening on http${isSecure ? "s" : ""}
|
|
103
|
-
bundleConfig.
|
|
104
|
-
} and is shared in the local network.`
|
|
102
|
+
`💻 Server listening on http${isSecure ? "s" : ""}://${
|
|
103
|
+
bundleConfig.host === "::" ? "localhost" : bundleConfig.host
|
|
104
|
+
}:${bundleConfig.port} and is shared in the local network.`
|
|
105
105
|
);
|
|
106
106
|
|
|
107
107
|
console.log(`⌛ Waiting for file changes ...`);
|
|
108
108
|
|
|
109
|
+
const chokidarOptions = { awaitWriteFinish: false };
|
|
109
110
|
if (postcssFile) {
|
|
110
|
-
const postCSSWatcher = watch(postcssFile);
|
|
111
|
+
const postCSSWatcher = watch(postcssFile, chokidarOptions);
|
|
111
112
|
const tailwindCSSWatcher = watch(
|
|
112
|
-
postcssFile.replace("postcss", "tailwind")
|
|
113
|
+
postcssFile.replace("postcss", "tailwind"),
|
|
114
|
+
chokidarOptions
|
|
113
115
|
); // Assuming that the file ext is the same
|
|
114
116
|
const tsConfigWatcher = watch(
|
|
115
|
-
postcssFile.split("\\").slice(0, -1).join("\\") + "\\tsconfig.json"
|
|
117
|
+
postcssFile.split("\\").slice(0, -1).join("\\") + "\\tsconfig.json",
|
|
118
|
+
chokidarOptions
|
|
116
119
|
);
|
|
117
120
|
|
|
118
121
|
const cssFiles = files.filter((file) => file.endsWith(".css"));
|
|
@@ -130,7 +133,7 @@ async function build(files: string[], firstRun = true) {
|
|
|
130
133
|
});
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
const watcher = watch(bundleConfig.src);
|
|
136
|
+
const watcher = watch(bundleConfig.src, chokidarOptions);
|
|
134
137
|
watcher.on("add", async (file) => {
|
|
135
138
|
file = String.raw`${file}`.replace(/\\/g, "/"); // glob and chokidar diff
|
|
136
139
|
if (files.includes(file) || INLINE_BUNDLE_FILE.test(file)) {
|
package/src/config.d.ts
CHANGED
package/src/utils.mts
CHANGED
|
@@ -44,8 +44,8 @@ export async function createDefaultServer(isSecure: boolean) {
|
|
|
44
44
|
? ({
|
|
45
45
|
http2: true,
|
|
46
46
|
https: {
|
|
47
|
-
key:
|
|
48
|
-
cert:
|
|
47
|
+
key: bundleConfig.key,
|
|
48
|
+
cert: bundleConfig.cert,
|
|
49
49
|
},
|
|
50
50
|
} as FastifyServerOptions)
|
|
51
51
|
: void 0
|
|
@@ -103,6 +103,9 @@ async function getBundleConfig(): Promise<Config> {
|
|
|
103
103
|
hmr: false,
|
|
104
104
|
secure: false,
|
|
105
105
|
handler: "",
|
|
106
|
+
host: "::",
|
|
107
|
+
key: await readFile(path.join(process.cwd(), "localhost-key.pem")),
|
|
108
|
+
cert: await readFile(path.join(process.cwd(), "localhost.pem")),
|
|
106
109
|
};
|
|
107
110
|
|
|
108
111
|
try {
|