html-bundle 6.0.17 → 6.0.18
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 +5 -5
- package/dist/utils.mjs +4 -4
- package/package.json +1 -1
- package/src/bundle.mts +5 -5
- package/src/utils.mts +4 -9
package/dist/bundle.mjs
CHANGED
|
@@ -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,
|
|
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,
|
|
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,
|
|
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(
|
|
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(
|
|
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}
|
|
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,
|
|
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}
|
|
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
package/src/bundle.mts
CHANGED
|
@@ -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,
|
|
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,
|
|
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,
|
|
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(
|
|
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(
|
|
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,
|
|
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),
|