html-bundle 6.0.17 → 6.0.19

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);
@@ -98,7 +98,7 @@ async function build(files, firstRun = true) {
98
98
  }
99
99
  const watcher = watch(bundleConfig.src);
100
100
  watcher.on("add", async (file) => {
101
- file = String.raw `${file}`.replace(/\\/g, sep); // glob and chokidar diff
101
+ file = String.raw `${file}`.replace(/\\/g, "/"); // glob and chokidar diff
102
102
  if (files.includes(file) || INLINE_BUNDLE_FILE.test(file)) {
103
103
  return;
104
104
  }
@@ -109,7 +109,7 @@ async function build(files, firstRun = true) {
109
109
  if (INLINE_BUNDLE_FILE.test(file)) {
110
110
  return;
111
111
  }
112
- file = String.raw `${file}`.replace(/\\/g, sep);
112
+ file = String.raw `${file}`.replace(/\\/g, "/");
113
113
  await rebuild(file);
114
114
  console.log(`⚡ modified ${file} on the build`);
115
115
  });
@@ -117,13 +117,13 @@ async function build(files, firstRun = true) {
117
117
  if (INLINE_BUNDLE_FILE.test(file)) {
118
118
  return;
119
119
  }
120
- file = String.raw `${file}`.replace(/\\/g, sep);
120
+ file = String.raw `${file}`.replace(/\\/g, "/");
121
121
  inlineFiles.delete(file);
122
122
  const buildFile = getBuildPath(file)
123
123
  .replace(".ts", ".js")
124
124
  .replace(".jsx", ".js");
125
125
  await rm(buildFile);
126
- const bfDir = buildFile.split(sep).slice(0, -1).join(sep);
126
+ const bfDir = buildFile.split("/").slice(0, -1).join("/");
127
127
  const stats = await readdir(bfDir);
128
128
  if (!stats.length)
129
129
  await rm(bfDir);
@@ -337,7 +337,7 @@ async function rebuildCSS(files, config) {
337
337
  }
338
338
  try {
339
339
  const files = await glob(`${bundleConfig.src}/**/*`);
340
- await build(files);
340
+ await build(files.map((file) => file.replaceAll(sep, "/")));
341
341
  }
342
342
  catch (err) {
343
343
  console.error(err);
package/dist/utils.mjs CHANGED
@@ -12,11 +12,11 @@ export function fileCopy(file) {
12
12
  }
13
13
  export function createDir(file) {
14
14
  const buildPath = getBuildPath(file);
15
- const dir = buildPath.split(path.sep).slice(0, -1).join(path.sep);
15
+ const dir = buildPath.split("/").slice(0, -1).join("/");
16
16
  return mkdir(dir, { recursive: true });
17
17
  }
18
18
  export function getBuildPath(file) {
19
- return file.replace(`${bundleConfig.src}${path.sep}`, `${bundleConfig.build}${path.sep}`);
19
+ return file.replace(`${bundleConfig.src}/`, `${bundleConfig.build}/`);
20
20
  }
21
21
  const CONNECTIONS = []; // In order to send the HMR information
22
22
  export let serverSentEvents;
@@ -31,11 +31,11 @@ export async function createDefaultServer(isSecure) {
31
31
  }
32
32
  : void 0);
33
33
  fastify.setNotFoundHandler(async (_req, reply) => {
34
- const file = await readFile(path.join(process.cwd(), bundleConfig.build, `${path.sep}index.html`), {
34
+ const file = await readFile(path.join(process.cwd(), bundleConfig.build, "/index.html"), {
35
35
  encoding: "utf-8",
36
36
  });
37
37
  reply.header("Content-Type", "text/html; charset=UTF-8");
38
- return reply.send(addHMRCode(file, `${bundleConfig.src}${path.sep}index.html`));
38
+ return reply.send(addHMRCode(file, `${bundleConfig.src}/index.html`));
39
39
  });
40
40
  fastify.register(fastifyStatic, {
41
41
  root: path.join(process.cwd(), bundleConfig.build),
package/package.json CHANGED
@@ -1,49 +1,49 @@
1
- {
2
- "name": "html-bundle",
3
- "version": "6.0.17",
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.19",
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.9",
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
 
@@ -132,7 +132,7 @@ async function build(files: string[], firstRun = true) {
132
132
 
133
133
  const watcher = watch(bundleConfig.src);
134
134
  watcher.on("add", async (file) => {
135
- file = String.raw`${file}`.replace(/\\/g, sep); // glob and chokidar diff
135
+ file = String.raw`${file}`.replace(/\\/g, "/"); // glob and chokidar diff
136
136
  if (files.includes(file) || INLINE_BUNDLE_FILE.test(file)) {
137
137
  return;
138
138
  }
@@ -145,7 +145,7 @@ async function build(files: string[], firstRun = true) {
145
145
  if (INLINE_BUNDLE_FILE.test(file)) {
146
146
  return;
147
147
  }
148
- file = String.raw`${file}`.replace(/\\/g, sep);
148
+ file = String.raw`${file}`.replace(/\\/g, "/");
149
149
 
150
150
  await rebuild(file);
151
151
 
@@ -155,7 +155,7 @@ async function build(files: string[], firstRun = true) {
155
155
  if (INLINE_BUNDLE_FILE.test(file)) {
156
156
  return;
157
157
  }
158
- file = String.raw`${file}`.replace(/\\/g, sep);
158
+ file = String.raw`${file}`.replace(/\\/g, "/");
159
159
 
160
160
  inlineFiles.delete(file);
161
161
  const buildFile = getBuildPath(file)
@@ -163,7 +163,7 @@ async function build(files: string[], firstRun = true) {
163
163
  .replace(".jsx", ".js");
164
164
  await rm(buildFile);
165
165
 
166
- const bfDir = buildFile.split(sep).slice(0, -1).join(sep);
166
+ const bfDir = buildFile.split("/").slice(0, -1).join("/");
167
167
  const stats = await readdir(bfDir);
168
168
  if (!stats.length) await rm(bfDir);
169
169
 
@@ -399,7 +399,7 @@ async function rebuildCSS(files: string[], config?: string) {
399
399
 
400
400
  try {
401
401
  const files = await glob(`${bundleConfig.src}/**/*`);
402
- await build(files);
402
+ await build(files.map((file) => file.replaceAll(sep, "/")));
403
403
  } catch (err) {
404
404
  console.error(err);
405
405
  process.exit(1);
package/src/utils.mts CHANGED
@@ -22,15 +22,12 @@ export function fileCopy(file: string) {
22
22
 
23
23
  export function createDir(file: string) {
24
24
  const buildPath = getBuildPath(file);
25
- const dir = buildPath.split(path.sep).slice(0, -1).join(path.sep);
25
+ const dir = buildPath.split("/").slice(0, -1).join("/");
26
26
  return mkdir(dir, { recursive: true });
27
27
  }
28
28
 
29
29
  export function getBuildPath(file: string) {
30
- return file.replace(
31
- `${bundleConfig.src}${path.sep}`,
32
- `${bundleConfig.build}${path.sep}`
33
- );
30
+ return file.replace(`${bundleConfig.src}/`, `${bundleConfig.build}/`);
34
31
  }
35
32
 
36
33
  const CONNECTIONS: Array<any> = []; // In order to send the HMR information
@@ -51,15 +48,13 @@ export async function createDefaultServer(isSecure: boolean) {
51
48
  );
52
49
  fastify.setNotFoundHandler(async (_req, reply) => {
53
50
  const file = await readFile(
54
- path.join(process.cwd(), bundleConfig.build, `${path.sep}index.html`),
51
+ path.join(process.cwd(), bundleConfig.build, "/index.html"),
55
52
  {
56
53
  encoding: "utf-8",
57
54
  }
58
55
  );
59
56
  reply.header("Content-Type", "text/html; charset=UTF-8");
60
- return reply.send(
61
- addHMRCode(file, `${bundleConfig.src}${path.sep}index.html`)
62
- );
57
+ return reply.send(addHMRCode(file, `${bundleConfig.src}/index.html`));
63
58
  });
64
59
  fastify.register(fastifyStatic, {
65
60
  root: path.join(process.cwd(), bundleConfig.build),
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
  }