@absolutejs/absolute 0.16.12 → 0.17.0
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/.absolutejs/prettier.cache.json +13 -9
- package/.absolutejs/tsconfig.tsbuildinfo +1 -1
- package/.claude/settings.local.json +2 -1
- package/dist/cli/index.js +283 -15
- package/dist/index.js +334 -179
- package/dist/index.js.map +11 -9
- package/dist/src/cli/scripts/info.d.ts +1 -0
- package/dist/src/cli/scripts/telemetry.d.ts +5 -0
- package/dist/src/cli/telemetryEvent.d.ts +1 -0
- package/dist/src/dev/pathUtils.d.ts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/telemetry.d.ts +15 -0
- package/package.json +2 -2
- package/types/index.ts +1 -0
- package/types/telemetry.ts +16 -0
- package/hmr-react-macos-fix.md +0 -113
package/dist/index.js
CHANGED
|
@@ -38,14 +38,14 @@ var exports_compileSvelte = {};
|
|
|
38
38
|
__export(exports_compileSvelte, {
|
|
39
39
|
compileSvelte: () => compileSvelte
|
|
40
40
|
});
|
|
41
|
-
import { existsSync as
|
|
41
|
+
import { existsSync as existsSync4 } from "fs";
|
|
42
42
|
import { mkdir as mkdir2, stat } from "fs/promises";
|
|
43
43
|
import {
|
|
44
44
|
dirname,
|
|
45
|
-
join as
|
|
45
|
+
join as join4,
|
|
46
46
|
basename as basename2,
|
|
47
47
|
extname as extname2,
|
|
48
|
-
resolve as
|
|
48
|
+
resolve as resolve5,
|
|
49
49
|
relative as relative2,
|
|
50
50
|
sep
|
|
51
51
|
} from "path";
|
|
@@ -59,7 +59,7 @@ var devClientDir2, hmrClientPath3, transpiler, exists = async (path) => {
|
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
}, resolveSvelte = async (spec, from) => {
|
|
62
|
-
const basePath =
|
|
62
|
+
const basePath = resolve5(dirname(from), spec);
|
|
63
63
|
const explicit = /\.(svelte|svelte\.(?:ts|js))$/.test(basePath);
|
|
64
64
|
if (!explicit) {
|
|
65
65
|
const extensions = [".svelte", ".svelte.ts", ".svelte.js"];
|
|
@@ -81,10 +81,10 @@ var devClientDir2, hmrClientPath3, transpiler, exists = async (path) => {
|
|
|
81
81
|
return null;
|
|
82
82
|
}, compileSvelte = async (entryPoints, svelteRoot, cache = new Map, isDev = false) => {
|
|
83
83
|
const { compile, compileModule, preprocess } = await import("svelte/compiler");
|
|
84
|
-
const compiledRoot =
|
|
85
|
-
const clientDir =
|
|
86
|
-
const indexDir =
|
|
87
|
-
const pagesDir =
|
|
84
|
+
const compiledRoot = join4(svelteRoot, "compiled");
|
|
85
|
+
const clientDir = join4(compiledRoot, "client");
|
|
86
|
+
const indexDir = join4(compiledRoot, "indexes");
|
|
87
|
+
const pagesDir = join4(compiledRoot, "pages");
|
|
88
88
|
await Promise.all([clientDir, indexDir, pagesDir].map((dir) => mkdir2(dir, { recursive: true })));
|
|
89
89
|
const dev = env.NODE_ENV !== "production";
|
|
90
90
|
const build2 = async (src) => {
|
|
@@ -110,8 +110,8 @@ var devClientDir2, hmrClientPath3, transpiler, exists = async (path) => {
|
|
|
110
110
|
filename: src,
|
|
111
111
|
generate: mode
|
|
112
112
|
}).js.code).replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
113
|
-
const ssrPath =
|
|
114
|
-
const clientPath =
|
|
113
|
+
const ssrPath = join4(pagesDir, relDir, `${baseName}.js`);
|
|
114
|
+
const clientPath = join4(clientDir, relDir, `${baseName}.js`);
|
|
115
115
|
await Promise.all([
|
|
116
116
|
mkdir2(dirname(ssrPath), { recursive: true }),
|
|
117
117
|
mkdir2(dirname(clientPath), { recursive: true })
|
|
@@ -138,7 +138,7 @@ var devClientDir2, hmrClientPath3, transpiler, exists = async (path) => {
|
|
|
138
138
|
await Promise.all(roots.map(async ({ client: client2 }) => {
|
|
139
139
|
const relClientDir = dirname(relative2(clientDir, client2));
|
|
140
140
|
const name = basename2(client2, extname2(client2));
|
|
141
|
-
const indexPath =
|
|
141
|
+
const indexPath = join4(indexDir, relClientDir, `${name}.js`);
|
|
142
142
|
const importRaw = relative2(dirname(indexPath), client2).split(sep).join("/");
|
|
143
143
|
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
144
144
|
const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
@@ -190,7 +190,7 @@ if (typeof window !== "undefined") {
|
|
|
190
190
|
return {
|
|
191
191
|
svelteIndexPaths: roots.map(({ client: client2 }) => {
|
|
192
192
|
const rel = dirname(relative2(clientDir, client2));
|
|
193
|
-
return
|
|
193
|
+
return join4(indexDir, rel, basename2(client2));
|
|
194
194
|
}),
|
|
195
195
|
svelteClientPaths: roots.map(({ client: client2 }) => client2),
|
|
196
196
|
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
@@ -198,12 +198,12 @@ if (typeof window !== "undefined") {
|
|
|
198
198
|
};
|
|
199
199
|
var init_compileSvelte = __esm(() => {
|
|
200
200
|
devClientDir2 = (() => {
|
|
201
|
-
const fromSource =
|
|
202
|
-
if (
|
|
201
|
+
const fromSource = resolve5(import.meta.dir, "../dev/client");
|
|
202
|
+
if (existsSync4(fromSource))
|
|
203
203
|
return fromSource;
|
|
204
|
-
return
|
|
204
|
+
return resolve5(import.meta.dir, "./dev/client");
|
|
205
205
|
})();
|
|
206
|
-
hmrClientPath3 =
|
|
206
|
+
hmrClientPath3 = join4(devClientDir2, "hmrClient.ts").replace(/\\/g, "/");
|
|
207
207
|
transpiler = new Transpiler({ loader: "ts", target: "browser" });
|
|
208
208
|
});
|
|
209
209
|
|
|
@@ -216,9 +216,9 @@ __export(exports_compileVue, {
|
|
|
216
216
|
compileVue: () => compileVue,
|
|
217
217
|
clearVueHmrCaches: () => clearVueHmrCaches
|
|
218
218
|
});
|
|
219
|
-
import { existsSync as
|
|
219
|
+
import { existsSync as existsSync5 } from "fs";
|
|
220
220
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
221
|
-
import { basename as basename3, dirname as dirname2, join as
|
|
221
|
+
import { basename as basename3, dirname as dirname2, join as join5, relative as relative3, resolve as resolve6 } from "path";
|
|
222
222
|
var {file: file2, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
|
|
223
223
|
var devClientDir3, hmrClientPath4, transpiler2, scriptCache, scriptSetupCache, templateCache, styleCache, vueHmrMetadata, detectVueChangeType = (filePath, descriptor) => {
|
|
224
224
|
const prevScript = scriptCache.get(filePath);
|
|
@@ -300,7 +300,7 @@ var devClientDir3, hmrClientPath4, transpiler2, scriptCache, scriptSetupCache, t
|
|
|
300
300
|
const importPaths = extractImports(scriptSource);
|
|
301
301
|
const childComponentPaths = importPaths.filter((path) => path.startsWith(".") && path.endsWith(".vue"));
|
|
302
302
|
const helperModulePaths = importPaths.filter((path) => path.startsWith(".") && !path.endsWith(".vue"));
|
|
303
|
-
const childBuildResults = await Promise.all(childComponentPaths.map((relativeChildPath) => compileVueFile(
|
|
303
|
+
const childBuildResults = await Promise.all(childComponentPaths.map((relativeChildPath) => compileVueFile(resolve6(dirname2(sourceFilePath), relativeChildPath), outputDirs, cacheMap, false, vueRootDir, compiler)));
|
|
304
304
|
const compiledScript = compiler.compileScript(descriptor, {
|
|
305
305
|
id: componentId,
|
|
306
306
|
inlineTemplate: false
|
|
@@ -332,7 +332,7 @@ var devClientDir3, hmrClientPath4, transpiler2, scriptCache, scriptSetupCache, t
|
|
|
332
332
|
];
|
|
333
333
|
let cssOutputPaths = [];
|
|
334
334
|
if (isEntryPoint && allCss.length) {
|
|
335
|
-
const cssOutputFile =
|
|
335
|
+
const cssOutputFile = join5(outputDirs.css, `${toKebab(fileBaseName)}.css`);
|
|
336
336
|
await mkdir3(dirname2(cssOutputFile), { recursive: true });
|
|
337
337
|
await write2(cssOutputFile, allCss.join(`
|
|
338
338
|
`));
|
|
@@ -363,8 +363,8 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
363
363
|
};
|
|
364
364
|
const clientCode = assembleModule(generateRenderFunction(false), "render", true);
|
|
365
365
|
const serverCode = assembleModule(generateRenderFunction(true), "ssrRender", false);
|
|
366
|
-
const clientOutputPath =
|
|
367
|
-
const serverOutputPath =
|
|
366
|
+
const clientOutputPath = join5(outputDirs.client, `${relativeWithoutExtension}.js`);
|
|
367
|
+
const serverOutputPath = join5(outputDirs.server, `${relativeWithoutExtension}.js`);
|
|
368
368
|
await mkdir3(dirname2(clientOutputPath), { recursive: true });
|
|
369
369
|
await mkdir3(dirname2(serverOutputPath), { recursive: true });
|
|
370
370
|
await write2(clientOutputPath, clientCode);
|
|
@@ -375,7 +375,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
375
375
|
cssPaths: cssOutputPaths,
|
|
376
376
|
serverPath: serverOutputPath,
|
|
377
377
|
tsHelperPaths: [
|
|
378
|
-
...helperModulePaths.map((helper) =>
|
|
378
|
+
...helperModulePaths.map((helper) => resolve6(dirname2(sourceFilePath), helper.endsWith(".ts") ? helper : `${helper}.ts`)),
|
|
379
379
|
...childBuildResults.flatMap((child) => child.tsHelperPaths)
|
|
380
380
|
],
|
|
381
381
|
hmrId
|
|
@@ -384,11 +384,11 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
384
384
|
return result;
|
|
385
385
|
}, compileVue = async (entryPoints, vueRootDir, isDev = false) => {
|
|
386
386
|
const compiler = await import("@vue/compiler-sfc");
|
|
387
|
-
const compiledOutputRoot =
|
|
388
|
-
const clientOutputDir =
|
|
389
|
-
const indexOutputDir =
|
|
390
|
-
const serverOutputDir =
|
|
391
|
-
const cssOutputDir =
|
|
387
|
+
const compiledOutputRoot = join5(vueRootDir, "compiled");
|
|
388
|
+
const clientOutputDir = join5(compiledOutputRoot, "client");
|
|
389
|
+
const indexOutputDir = join5(compiledOutputRoot, "indexes");
|
|
390
|
+
const serverOutputDir = join5(compiledOutputRoot, "pages");
|
|
391
|
+
const cssOutputDir = join5(compiledOutputRoot, "styles");
|
|
392
392
|
await Promise.all([
|
|
393
393
|
mkdir3(clientOutputDir, { recursive: true }),
|
|
394
394
|
mkdir3(indexOutputDir, { recursive: true }),
|
|
@@ -398,15 +398,15 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
398
398
|
const buildCache = new Map;
|
|
399
399
|
const allTsHelperPaths = new Set;
|
|
400
400
|
const compiledPages = await Promise.all(entryPoints.map(async (entryPath) => {
|
|
401
|
-
const result = await compileVueFile(
|
|
401
|
+
const result = await compileVueFile(resolve6(entryPath), {
|
|
402
402
|
client: clientOutputDir,
|
|
403
403
|
css: cssOutputDir,
|
|
404
404
|
server: serverOutputDir
|
|
405
405
|
}, buildCache, true, vueRootDir, compiler);
|
|
406
406
|
result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
|
|
407
407
|
const entryBaseName = basename3(entryPath, ".vue");
|
|
408
|
-
const indexOutputFile =
|
|
409
|
-
const clientOutputFile =
|
|
408
|
+
const indexOutputFile = join5(indexOutputDir, `${entryBaseName}.js`);
|
|
409
|
+
const clientOutputFile = join5(clientOutputDir, relative3(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
|
|
410
410
|
await mkdir3(dirname2(indexOutputFile), { recursive: true });
|
|
411
411
|
const vueHmrImports = isDev ? [
|
|
412
412
|
`window.__HMR_FRAMEWORK__ = "vue";`,
|
|
@@ -514,8 +514,8 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
514
514
|
const sourceCode = await file2(tsPath).text();
|
|
515
515
|
const transpiledCode = transpiler2.transformSync(sourceCode);
|
|
516
516
|
const relativeJsPath = relative3(vueRootDir, tsPath).replace(/\.ts$/, ".js");
|
|
517
|
-
const outClientPath =
|
|
518
|
-
const outServerPath =
|
|
517
|
+
const outClientPath = join5(clientOutputDir, relativeJsPath);
|
|
518
|
+
const outServerPath = join5(serverOutputDir, relativeJsPath);
|
|
519
519
|
await mkdir3(dirname2(outClientPath), { recursive: true });
|
|
520
520
|
await mkdir3(dirname2(outServerPath), { recursive: true });
|
|
521
521
|
await write2(outClientPath, transpiledCode);
|
|
@@ -531,12 +531,12 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
531
531
|
};
|
|
532
532
|
var init_compileVue = __esm(() => {
|
|
533
533
|
devClientDir3 = (() => {
|
|
534
|
-
const fromSource =
|
|
535
|
-
if (
|
|
534
|
+
const fromSource = resolve6(import.meta.dir, "../dev/client");
|
|
535
|
+
if (existsSync5(fromSource))
|
|
536
536
|
return fromSource;
|
|
537
|
-
return
|
|
537
|
+
return resolve6(import.meta.dir, "./dev/client");
|
|
538
538
|
})();
|
|
539
|
-
hmrClientPath4 =
|
|
539
|
+
hmrClientPath4 = join5(devClientDir3, "hmrClient.ts").replace(/\\/g, "/");
|
|
540
540
|
transpiler2 = new Transpiler2({ loader: "ts", target: "browser" });
|
|
541
541
|
scriptCache = new Map;
|
|
542
542
|
scriptSetupCache = new Map;
|
|
@@ -550,15 +550,15 @@ var exports_simpleHTMLHMR = {};
|
|
|
550
550
|
__export(exports_simpleHTMLHMR, {
|
|
551
551
|
handleHTMLUpdate: () => handleHTMLUpdate
|
|
552
552
|
});
|
|
553
|
-
import { readFileSync as
|
|
554
|
-
import { resolve as
|
|
553
|
+
import { readFileSync as readFileSync6, existsSync as existsSync8 } from "fs";
|
|
554
|
+
import { resolve as resolve14 } from "path";
|
|
555
555
|
var handleHTMLUpdate = async (htmlFilePath) => {
|
|
556
556
|
try {
|
|
557
|
-
const resolvedPath =
|
|
558
|
-
if (!
|
|
557
|
+
const resolvedPath = resolve14(htmlFilePath);
|
|
558
|
+
if (!existsSync8(resolvedPath)) {
|
|
559
559
|
return null;
|
|
560
560
|
}
|
|
561
|
-
const htmlContent =
|
|
561
|
+
const htmlContent = readFileSync6(resolvedPath, "utf-8");
|
|
562
562
|
const headMatch = htmlContent.match(/<head[^>]*>([\s\S]*?)<\/head>/i);
|
|
563
563
|
const bodyMatch = htmlContent.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
|
564
564
|
if (bodyMatch && bodyMatch[1]) {
|
|
@@ -696,10 +696,10 @@ var exports_simpleVueHMR = {};
|
|
|
696
696
|
__export(exports_simpleVueHMR, {
|
|
697
697
|
handleVueUpdate: () => handleVueUpdate
|
|
698
698
|
});
|
|
699
|
-
import { basename as basename6, join as
|
|
699
|
+
import { basename as basename6, join as join9, resolve as resolve15 } from "path";
|
|
700
700
|
var handleVueUpdate = async (vueFilePath, manifest, buildDir) => {
|
|
701
701
|
try {
|
|
702
|
-
const resolvedPath =
|
|
702
|
+
const resolvedPath = resolve15(vueFilePath);
|
|
703
703
|
const fileName = basename6(resolvedPath);
|
|
704
704
|
const baseName = fileName.replace(/\.vue$/, "");
|
|
705
705
|
const pascalName = toPascal(baseName);
|
|
@@ -712,7 +712,7 @@ var handleVueUpdate = async (vueFilePath, manifest, buildDir) => {
|
|
|
712
712
|
console.warn("[Vue HMR] Available manifest keys:", Object.keys(manifest).join(", "));
|
|
713
713
|
return null;
|
|
714
714
|
}
|
|
715
|
-
const absoluteServerPath =
|
|
715
|
+
const absoluteServerPath = resolve15(serverPath) === serverPath || serverPath.startsWith("/") || /^[A-Za-z]:[\\/]/.test(serverPath) ? serverPath : join9(buildDir || process.cwd(), serverPath.replace(/^\//, ""));
|
|
716
716
|
const cacheBuster = `?t=${Date.now()}`;
|
|
717
717
|
const serverModule = await import(`${absoluteServerPath}${cacheBuster}`);
|
|
718
718
|
if (!serverModule || !serverModule.default) {
|
|
@@ -844,10 +844,10 @@ var exports_simpleSvelteHMR = {};
|
|
|
844
844
|
__export(exports_simpleSvelteHMR, {
|
|
845
845
|
handleSvelteUpdate: () => handleSvelteUpdate
|
|
846
846
|
});
|
|
847
|
-
import { basename as basename7, join as
|
|
847
|
+
import { basename as basename7, join as join10, resolve as resolve16 } from "path";
|
|
848
848
|
var handleSvelteUpdate = async (svelteFilePath, manifest, buildDir) => {
|
|
849
849
|
try {
|
|
850
|
-
const resolvedPath =
|
|
850
|
+
const resolvedPath = resolve16(svelteFilePath);
|
|
851
851
|
const fileName = basename7(resolvedPath);
|
|
852
852
|
const baseName = fileName.replace(/\.svelte$/, "");
|
|
853
853
|
const pascalName = toPascal(baseName);
|
|
@@ -860,7 +860,7 @@ var handleSvelteUpdate = async (svelteFilePath, manifest, buildDir) => {
|
|
|
860
860
|
console.warn("[Svelte HMR] Available manifest keys:", Object.keys(manifest).join(", "));
|
|
861
861
|
return null;
|
|
862
862
|
}
|
|
863
|
-
const absoluteServerPath =
|
|
863
|
+
const absoluteServerPath = resolve16(serverPath) === serverPath || serverPath.startsWith("/") || /^[A-Za-z]:[\\/]/.test(serverPath) ? serverPath : join10(buildDir || process.cwd(), serverPath.replace(/^\//, ""));
|
|
864
864
|
const cacheBuster = `?t=${Date.now()}`;
|
|
865
865
|
const serverModule = await import(`${absoluteServerPath}${cacheBuster}`);
|
|
866
866
|
if (!serverModule || !serverModule.default) {
|
|
@@ -896,15 +896,15 @@ var exports_simpleHTMXHMR = {};
|
|
|
896
896
|
__export(exports_simpleHTMXHMR, {
|
|
897
897
|
handleHTMXUpdate: () => handleHTMXUpdate
|
|
898
898
|
});
|
|
899
|
-
import { readFileSync as
|
|
900
|
-
import { resolve as
|
|
899
|
+
import { readFileSync as readFileSync7, existsSync as existsSync9 } from "fs";
|
|
900
|
+
import { resolve as resolve17 } from "path";
|
|
901
901
|
var handleHTMXUpdate = async (htmxFilePath) => {
|
|
902
902
|
try {
|
|
903
|
-
const resolvedPath =
|
|
904
|
-
if (!
|
|
903
|
+
const resolvedPath = resolve17(htmxFilePath);
|
|
904
|
+
if (!existsSync9(resolvedPath)) {
|
|
905
905
|
return null;
|
|
906
906
|
}
|
|
907
|
-
const htmlContent =
|
|
907
|
+
const htmlContent = readFileSync7(resolvedPath, "utf-8");
|
|
908
908
|
const headMatch = htmlContent.match(/<head[^>]*>([\s\S]*?)<\/head>/i);
|
|
909
909
|
const bodyMatch = htmlContent.match(/<body[^>]*>([\s\S]*)<\/body>/i);
|
|
910
910
|
if (bodyMatch && bodyMatch[1]) {
|
|
@@ -960,12 +960,12 @@ init_constants();
|
|
|
960
960
|
import {
|
|
961
961
|
copyFileSync,
|
|
962
962
|
cpSync,
|
|
963
|
-
mkdirSync,
|
|
964
|
-
readFileSync,
|
|
965
|
-
writeFileSync
|
|
963
|
+
mkdirSync as mkdirSync2,
|
|
964
|
+
readFileSync as readFileSync3,
|
|
965
|
+
writeFileSync as writeFileSync2
|
|
966
966
|
} from "fs";
|
|
967
967
|
import { rm as rm3 } from "fs/promises";
|
|
968
|
-
import { basename as basename4, join as
|
|
968
|
+
import { basename as basename4, join as join6, resolve as resolve7 } from "path";
|
|
969
969
|
import { cwd, env as env2, exit } from "process";
|
|
970
970
|
var {$, build: bunBuild2, Glob: Glob3 } = globalThis.Bun;
|
|
971
971
|
|
|
@@ -1379,6 +1379,63 @@ var scanEntryPoints = async (dir, pattern) => {
|
|
|
1379
1379
|
|
|
1380
1380
|
// src/build/updateAssetPaths.ts
|
|
1381
1381
|
import { readFile, writeFile as writeFile2 } from "fs/promises";
|
|
1382
|
+
|
|
1383
|
+
// src/cli/telemetryEvent.ts
|
|
1384
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
1385
|
+
import { arch, platform } from "os";
|
|
1386
|
+
import { resolve as resolve2 } from "path";
|
|
1387
|
+
|
|
1388
|
+
// src/cli/scripts/telemetry.ts
|
|
1389
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
1390
|
+
import { homedir } from "os";
|
|
1391
|
+
import { join as join2 } from "path";
|
|
1392
|
+
var configDir = join2(homedir(), ".absolutejs");
|
|
1393
|
+
var configPath = join2(configDir, "telemetry.json");
|
|
1394
|
+
var getTelemetryConfig = () => {
|
|
1395
|
+
try {
|
|
1396
|
+
if (!existsSync2(configPath))
|
|
1397
|
+
return null;
|
|
1398
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
1399
|
+
return JSON.parse(raw);
|
|
1400
|
+
} catch {
|
|
1401
|
+
return null;
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
|
|
1405
|
+
// src/cli/telemetryEvent.ts
|
|
1406
|
+
var __dirname = "/home/alexkahn/abs/absolutejs/src/cli";
|
|
1407
|
+
var getVersion = () => {
|
|
1408
|
+
try {
|
|
1409
|
+
const pkgPath = resolve2(__dirname, "../../package.json");
|
|
1410
|
+
const pkg = JSON.parse(readFileSync2(pkgPath, "utf-8"));
|
|
1411
|
+
return pkg.version;
|
|
1412
|
+
} catch {
|
|
1413
|
+
return "unknown";
|
|
1414
|
+
}
|
|
1415
|
+
};
|
|
1416
|
+
var sendTelemetryEvent = (event, payload) => {
|
|
1417
|
+
try {
|
|
1418
|
+
const config = getTelemetryConfig();
|
|
1419
|
+
if (!config?.enabled)
|
|
1420
|
+
return;
|
|
1421
|
+
const body = {
|
|
1422
|
+
event,
|
|
1423
|
+
anonymousId: config.anonymousId,
|
|
1424
|
+
version: getVersion(),
|
|
1425
|
+
os: platform(),
|
|
1426
|
+
arch: arch(),
|
|
1427
|
+
bunVersion: Bun.version,
|
|
1428
|
+
timestamp: new Date().toISOString(),
|
|
1429
|
+
payload
|
|
1430
|
+
};
|
|
1431
|
+
fetch("https://absolutejs.com/api/telemetry", {
|
|
1432
|
+
method: "POST",
|
|
1433
|
+
headers: { "Content-Type": "application/json" },
|
|
1434
|
+
body: JSON.stringify(body)
|
|
1435
|
+
}).catch(() => {});
|
|
1436
|
+
} catch {}
|
|
1437
|
+
};
|
|
1438
|
+
// src/build/updateAssetPaths.ts
|
|
1382
1439
|
var updateAssetPaths = async (manifest, directory) => {
|
|
1383
1440
|
const htmlFiles = await scanEntryPoints(directory, "*.html");
|
|
1384
1441
|
const assetRegex = /((?:<script[^>]+src=|<link[^>]*?rel=["']stylesheet["'][^>]*?href=)["'])(?!\/?(?:.*\/)?htmx\.min\.js)(\/?(?:.*\/)?)([^./"']+)(?:\.[^."'/]+)?(\.(?:js|ts|css))(["'][^>]*>)/g;
|
|
@@ -1406,6 +1463,11 @@ var updateAssetPaths = async (manifest, directory) => {
|
|
|
1406
1463
|
return `${prefix}${newPath}${suffix}`;
|
|
1407
1464
|
}
|
|
1408
1465
|
console.error(`error: no manifest entry for ${ext.slice(1)} "${name}" referenced in ${filePath}`);
|
|
1466
|
+
sendTelemetryEvent("build:missing-manifest-entry", {
|
|
1467
|
+
assetName: name,
|
|
1468
|
+
assetType: ext.slice(1),
|
|
1469
|
+
htmlFile: filePath
|
|
1470
|
+
});
|
|
1409
1471
|
return match;
|
|
1410
1472
|
});
|
|
1411
1473
|
await writeFile2(filePath, updated, "utf8");
|
|
@@ -1414,14 +1476,14 @@ var updateAssetPaths = async (manifest, directory) => {
|
|
|
1414
1476
|
};
|
|
1415
1477
|
|
|
1416
1478
|
// src/dev/buildHMRClient.ts
|
|
1417
|
-
import { existsSync as
|
|
1479
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1480
|
+
import { resolve as resolve3 } from "path";
|
|
1418
1481
|
var {build: bunBuild } = globalThis.Bun;
|
|
1419
|
-
import { resolve as resolve2 } from "path";
|
|
1420
1482
|
var hmrClientPath2 = (() => {
|
|
1421
|
-
const fromSource =
|
|
1422
|
-
if (
|
|
1483
|
+
const fromSource = resolve3(import.meta.dir, "client/hmrClient.ts");
|
|
1484
|
+
if (existsSync3(fromSource))
|
|
1423
1485
|
return fromSource;
|
|
1424
|
-
return
|
|
1486
|
+
return resolve3(import.meta.dir, "dev/client/hmrClient.ts");
|
|
1425
1487
|
})();
|
|
1426
1488
|
var buildHMRClient = async () => {
|
|
1427
1489
|
const entryPoint = hmrClientPath2;
|
|
@@ -1433,6 +1495,10 @@ var buildHMRClient = async () => {
|
|
|
1433
1495
|
});
|
|
1434
1496
|
if (!result.success) {
|
|
1435
1497
|
console.error("Failed to build HMR client:", result.logs);
|
|
1498
|
+
sendTelemetryEvent("hmr:client-build-failed", {
|
|
1499
|
+
logCount: result.logs.length,
|
|
1500
|
+
message: result.logs.map((l) => l.message).join("; ")
|
|
1501
|
+
});
|
|
1436
1502
|
return "// HMR client build failed";
|
|
1437
1503
|
}
|
|
1438
1504
|
return await result.outputs[0].text();
|
|
@@ -1478,18 +1544,18 @@ var getDevVendorPaths = () => devVendorPaths;
|
|
|
1478
1544
|
|
|
1479
1545
|
// src/utils/cleanup.ts
|
|
1480
1546
|
import { rm as rm2 } from "fs/promises";
|
|
1481
|
-
import { join as
|
|
1547
|
+
import { join as join3 } from "path";
|
|
1482
1548
|
var cleanup = async ({
|
|
1483
1549
|
svelteDir,
|
|
1484
1550
|
vueDir,
|
|
1485
1551
|
reactIndexesPath
|
|
1486
1552
|
}) => {
|
|
1487
1553
|
await Promise.all([
|
|
1488
|
-
svelteDir ? rm2(
|
|
1554
|
+
svelteDir ? rm2(join3(svelteDir, "compiled"), {
|
|
1489
1555
|
force: true,
|
|
1490
1556
|
recursive: true
|
|
1491
1557
|
}) : undefined,
|
|
1492
|
-
vueDir ? rm2(
|
|
1558
|
+
vueDir ? rm2(join3(vueDir, "compiled"), { force: true, recursive: true }) : undefined,
|
|
1493
1559
|
reactIndexesPath ? rm2(reactIndexesPath, { force: true, recursive: true }) : undefined
|
|
1494
1560
|
]);
|
|
1495
1561
|
};
|
|
@@ -1647,10 +1713,10 @@ var logger = {
|
|
|
1647
1713
|
ready: startupBanner
|
|
1648
1714
|
};
|
|
1649
1715
|
// src/utils/validateSafePath.ts
|
|
1650
|
-
import { resolve as
|
|
1716
|
+
import { resolve as resolve4, relative } from "path";
|
|
1651
1717
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
1652
|
-
const absoluteBase =
|
|
1653
|
-
const absoluteTarget =
|
|
1718
|
+
const absoluteBase = resolve4(baseDirectory);
|
|
1719
|
+
const absoluteTarget = resolve4(baseDirectory, targetPath);
|
|
1654
1720
|
const relativePath = normalizePath(relative(absoluteBase, absoluteTarget));
|
|
1655
1721
|
if (relativePath.startsWith("../") || relativePath === "..") {
|
|
1656
1722
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
@@ -1693,14 +1759,14 @@ var build2 = async ({
|
|
|
1693
1759
|
const svelteDir = svelteDirectory && validateSafePath(svelteDirectory, projectRoot);
|
|
1694
1760
|
const vueDir = vueDirectory && validateSafePath(vueDirectory, projectRoot);
|
|
1695
1761
|
const angularDir = angularDirectory && validateSafePath(angularDirectory, projectRoot);
|
|
1696
|
-
const reactIndexesPath = reactDir &&
|
|
1697
|
-
const reactPagesPath = reactDir &&
|
|
1698
|
-
const htmlPagesPath = htmlDir &&
|
|
1699
|
-
const htmlScriptsPath = htmlDir &&
|
|
1700
|
-
const sveltePagesPath = svelteDir &&
|
|
1701
|
-
const vuePagesPath = vueDir &&
|
|
1702
|
-
const htmxPagesPath = htmxDir &&
|
|
1703
|
-
const angularPagesPath = angularDir &&
|
|
1762
|
+
const reactIndexesPath = reactDir && join6(reactDir, "indexes");
|
|
1763
|
+
const reactPagesPath = reactDir && join6(reactDir, "pages");
|
|
1764
|
+
const htmlPagesPath = htmlDir && join6(htmlDir, "pages");
|
|
1765
|
+
const htmlScriptsPath = htmlDir && join6(htmlDir, "scripts");
|
|
1766
|
+
const sveltePagesPath = svelteDir && join6(svelteDir, "pages");
|
|
1767
|
+
const vuePagesPath = vueDir && join6(vueDir, "pages");
|
|
1768
|
+
const htmxPagesPath = htmxDir && join6(htmxDir, "pages");
|
|
1769
|
+
const angularPagesPath = angularDir && join6(angularDir, "pages");
|
|
1704
1770
|
const frontends = [
|
|
1705
1771
|
reactDir,
|
|
1706
1772
|
htmlDir,
|
|
@@ -1710,6 +1776,19 @@ var build2 = async ({
|
|
|
1710
1776
|
angularDir
|
|
1711
1777
|
].filter(Boolean);
|
|
1712
1778
|
const isSingle = frontends.length === 1;
|
|
1779
|
+
const frameworkNames = [
|
|
1780
|
+
reactDir && "react",
|
|
1781
|
+
htmlDir && "html",
|
|
1782
|
+
htmxDir && "htmx",
|
|
1783
|
+
svelteDir && "svelte",
|
|
1784
|
+
vueDir && "vue",
|
|
1785
|
+
angularDir && "angular"
|
|
1786
|
+
].filter(Boolean);
|
|
1787
|
+
sendTelemetryEvent("build:start", {
|
|
1788
|
+
framework: frameworkNames[0],
|
|
1789
|
+
frameworks: frameworkNames,
|
|
1790
|
+
tailwind: !!tailwind
|
|
1791
|
+
});
|
|
1713
1792
|
const clientRoots = [
|
|
1714
1793
|
reactDir,
|
|
1715
1794
|
svelteDir,
|
|
@@ -1720,9 +1799,9 @@ var build2 = async ({
|
|
|
1720
1799
|
const clientRoot = isSingle ? clientRoots[0] ?? projectRoot : commonAncestor(clientRoots, projectRoot);
|
|
1721
1800
|
let serverOutDir;
|
|
1722
1801
|
if (svelteDir)
|
|
1723
|
-
serverOutDir =
|
|
1802
|
+
serverOutDir = join6(buildPath, basename4(svelteDir), "pages");
|
|
1724
1803
|
else if (vueDir)
|
|
1725
|
-
serverOutDir =
|
|
1804
|
+
serverOutDir = join6(buildPath, basename4(vueDir), "pages");
|
|
1726
1805
|
let serverRoot;
|
|
1727
1806
|
if (sveltePagesPath)
|
|
1728
1807
|
serverRoot = sveltePagesPath;
|
|
@@ -1732,17 +1811,17 @@ var build2 = async ({
|
|
|
1732
1811
|
if (!isIncremental) {
|
|
1733
1812
|
await rm3(buildPath, { force: true, recursive: true });
|
|
1734
1813
|
}
|
|
1735
|
-
|
|
1814
|
+
mkdirSync2(buildPath, { recursive: true });
|
|
1736
1815
|
if (publicPath)
|
|
1737
1816
|
cpSync(publicPath, buildPath, { force: true, recursive: true });
|
|
1738
1817
|
const filterToIncrementalEntries = (entryPoints, mapToSource) => {
|
|
1739
1818
|
if (!isIncremental || !incrementalFiles)
|
|
1740
1819
|
return entryPoints;
|
|
1741
|
-
const normalizedIncremental = new Set(incrementalFiles.map((f) =>
|
|
1820
|
+
const normalizedIncremental = new Set(incrementalFiles.map((f) => resolve7(f)));
|
|
1742
1821
|
const matchingEntries = [];
|
|
1743
1822
|
for (const entry of entryPoints) {
|
|
1744
1823
|
const sourceFile = mapToSource(entry);
|
|
1745
|
-
if (sourceFile && normalizedIncremental.has(
|
|
1824
|
+
if (sourceFile && normalizedIncremental.has(resolve7(sourceFile))) {
|
|
1746
1825
|
matchingEntries.push(entry);
|
|
1747
1826
|
}
|
|
1748
1827
|
}
|
|
@@ -1752,12 +1831,12 @@ var build2 = async ({
|
|
|
1752
1831
|
await generateReactIndexFiles(reactPagesPath, reactIndexesPath, hmr);
|
|
1753
1832
|
}
|
|
1754
1833
|
if (assetsPath && (!isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/assets/")))) {
|
|
1755
|
-
cpSync(assetsPath,
|
|
1834
|
+
cpSync(assetsPath, join6(buildPath, "assets"), {
|
|
1756
1835
|
force: true,
|
|
1757
1836
|
recursive: true
|
|
1758
1837
|
});
|
|
1759
1838
|
}
|
|
1760
|
-
const tailwindPromise = tailwind && (!isIncremental || normalizedIncrementalFiles?.some((f) => f.endsWith(".css"))) ? $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${
|
|
1839
|
+
const tailwindPromise = tailwind && (!isIncremental || normalizedIncrementalFiles?.some((f) => f.endsWith(".css"))) ? $`bunx @tailwindcss/cli -i ${tailwind.input} -o ${join6(buildPath, tailwind.output)}` : undefined;
|
|
1761
1840
|
const [
|
|
1762
1841
|
,
|
|
1763
1842
|
allReactEntries,
|
|
@@ -1776,17 +1855,17 @@ var build2 = async ({
|
|
|
1776
1855
|
sveltePagesPath ? scanEntryPoints(sveltePagesPath, "*.svelte") : [],
|
|
1777
1856
|
vuePagesPath ? scanEntryPoints(vuePagesPath, "*.vue") : [],
|
|
1778
1857
|
angularPagesPath ? scanEntryPoints(angularPagesPath, "*.ts") : [],
|
|
1779
|
-
htmlDir ? scanEntryPoints(
|
|
1780
|
-
htmxDir ? scanEntryPoints(
|
|
1781
|
-
reactDir ? scanEntryPoints(
|
|
1782
|
-
svelteDir ? scanEntryPoints(
|
|
1858
|
+
htmlDir ? scanEntryPoints(join6(htmlDir, "styles"), "*.css") : [],
|
|
1859
|
+
htmxDir ? scanEntryPoints(join6(htmxDir, "styles"), "*.css") : [],
|
|
1860
|
+
reactDir ? scanEntryPoints(join6(reactDir, "styles"), "*.css") : [],
|
|
1861
|
+
svelteDir ? scanEntryPoints(join6(svelteDir, "styles"), "*.css") : []
|
|
1783
1862
|
]);
|
|
1784
1863
|
const shouldIncludeHtmlAssets = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/html/") && (f.endsWith(".html") || f.endsWith(".css")));
|
|
1785
1864
|
const shouldIncludeHtmxAssets = !isIncremental || normalizedIncrementalFiles?.some((f) => f.includes("/htmx/") && (f.endsWith(".html") || f.endsWith(".css")));
|
|
1786
1865
|
const reactEntries = isIncremental && reactIndexesPath && reactPagesPath ? filterToIncrementalEntries(allReactEntries, (entry) => {
|
|
1787
|
-
if (entry.startsWith(
|
|
1866
|
+
if (entry.startsWith(resolve7(reactIndexesPath))) {
|
|
1788
1867
|
const pageName = basename4(entry, ".tsx");
|
|
1789
|
-
return
|
|
1868
|
+
return join6(reactPagesPath, `${pageName}.tsx`);
|
|
1790
1869
|
}
|
|
1791
1870
|
return null;
|
|
1792
1871
|
}) : allReactEntries;
|
|
@@ -1833,10 +1912,13 @@ var build2 = async ({
|
|
|
1833
1912
|
];
|
|
1834
1913
|
if (serverEntryPoints.length === 0 && reactClientEntryPoints.length === 0 && nonReactClientEntryPoints.length === 0 && htmxDir === undefined && htmlDir === undefined) {
|
|
1835
1914
|
logger.warn("No entry points found, manifest will be empty");
|
|
1915
|
+
sendTelemetryEvent("build:empty", {
|
|
1916
|
+
frameworks: frameworkNames
|
|
1917
|
+
});
|
|
1836
1918
|
return {};
|
|
1837
1919
|
}
|
|
1838
1920
|
if (hmr && reactIndexesPath && reactClientEntryPoints.length > 0) {
|
|
1839
|
-
const refreshEntry =
|
|
1921
|
+
const refreshEntry = join6(reactIndexesPath, "_refresh.tsx");
|
|
1840
1922
|
if (!reactClientEntryPoints.includes(refreshEntry)) {
|
|
1841
1923
|
reactClientEntryPoints.push(refreshEntry);
|
|
1842
1924
|
}
|
|
@@ -1891,7 +1973,7 @@ var build2 = async ({
|
|
|
1891
1973
|
cssEntryPoints.length > 0 ? bunBuild2({
|
|
1892
1974
|
entrypoints: cssEntryPoints,
|
|
1893
1975
|
naming: `[name].[hash].[ext]`,
|
|
1894
|
-
outdir:
|
|
1976
|
+
outdir: join6(buildPath, assetsPath ? basename4(assetsPath) : "assets", "css"),
|
|
1895
1977
|
target: "browser",
|
|
1896
1978
|
throw: false
|
|
1897
1979
|
}) : undefined
|
|
@@ -1905,6 +1987,12 @@ var build2 = async ({
|
|
|
1905
1987
|
const errLog = serverResult.logs.find((l) => l.level === "error") ?? serverResult.logs[0];
|
|
1906
1988
|
const err = new Error(typeof errLog.message === "string" ? errLog.message : String(errLog.message));
|
|
1907
1989
|
err.logs = serverResult.logs;
|
|
1990
|
+
sendTelemetryEvent("build:error", {
|
|
1991
|
+
pass: "server",
|
|
1992
|
+
frameworks: frameworkNames,
|
|
1993
|
+
message: err.message,
|
|
1994
|
+
incremental: !!isIncremental
|
|
1995
|
+
});
|
|
1908
1996
|
logger.error("Server build failed", err);
|
|
1909
1997
|
if (throwOnError)
|
|
1910
1998
|
throw err;
|
|
@@ -1920,6 +2008,12 @@ var build2 = async ({
|
|
|
1920
2008
|
const errLog = reactClientResult.logs.find((l) => l.level === "error") ?? reactClientResult.logs[0];
|
|
1921
2009
|
const err = new Error(typeof errLog.message === "string" ? errLog.message : String(errLog.message));
|
|
1922
2010
|
err.logs = reactClientResult.logs;
|
|
2011
|
+
sendTelemetryEvent("build:error", {
|
|
2012
|
+
pass: "react-client",
|
|
2013
|
+
frameworks: frameworkNames,
|
|
2014
|
+
message: err.message,
|
|
2015
|
+
incremental: !!isIncremental
|
|
2016
|
+
});
|
|
1923
2017
|
logger.error("React client build failed", err);
|
|
1924
2018
|
if (throwOnError)
|
|
1925
2019
|
throw err;
|
|
@@ -1938,6 +2032,12 @@ var build2 = async ({
|
|
|
1938
2032
|
const errLog = nonReactClientResult.logs.find((l) => l.level === "error") ?? nonReactClientResult.logs[0];
|
|
1939
2033
|
const err = new Error(typeof errLog.message === "string" ? errLog.message : String(errLog.message));
|
|
1940
2034
|
err.logs = nonReactClientResult.logs;
|
|
2035
|
+
sendTelemetryEvent("build:error", {
|
|
2036
|
+
pass: "non-react-client",
|
|
2037
|
+
frameworks: frameworkNames,
|
|
2038
|
+
message: err.message,
|
|
2039
|
+
incremental: !!isIncremental
|
|
2040
|
+
});
|
|
1941
2041
|
logger.error("Non-React client build failed", err);
|
|
1942
2042
|
if (throwOnError)
|
|
1943
2043
|
throw err;
|
|
@@ -1953,6 +2053,12 @@ var build2 = async ({
|
|
|
1953
2053
|
const errLog = cssResult.logs.find((l) => l.level === "error") ?? cssResult.logs[0];
|
|
1954
2054
|
const err = new Error(typeof errLog.message === "string" ? errLog.message : String(errLog.message));
|
|
1955
2055
|
err.logs = cssResult.logs;
|
|
2056
|
+
sendTelemetryEvent("build:error", {
|
|
2057
|
+
pass: "css",
|
|
2058
|
+
frameworks: frameworkNames,
|
|
2059
|
+
message: err.message,
|
|
2060
|
+
incremental: !!isIncremental
|
|
2061
|
+
});
|
|
1956
2062
|
logger.error("CSS build failed", err);
|
|
1957
2063
|
if (throwOnError)
|
|
1958
2064
|
throw err;
|
|
@@ -1989,21 +2095,21 @@ var build2 = async ({
|
|
|
1989
2095
|
const injectHMRIntoHTMLFile = (filePath, framework) => {
|
|
1990
2096
|
if (!hmrClientBundle)
|
|
1991
2097
|
return;
|
|
1992
|
-
let html =
|
|
2098
|
+
let html = readFileSync3(filePath, "utf-8");
|
|
1993
2099
|
if (html.includes("data-hmr-client"))
|
|
1994
2100
|
return;
|
|
1995
2101
|
const tag = `<script>window.__HMR_FRAMEWORK__="${framework}";</script>` + `<script data-hmr-client>${hmrClientBundle}</script>`;
|
|
1996
2102
|
const bodyClose = /<\/body\s*>/i.exec(html);
|
|
1997
2103
|
html = bodyClose ? html.slice(0, bodyClose.index) + tag + html.slice(bodyClose.index) : html + tag;
|
|
1998
|
-
|
|
2104
|
+
writeFileSync2(filePath, html);
|
|
1999
2105
|
};
|
|
2000
2106
|
await Promise.all([
|
|
2001
2107
|
(async () => {
|
|
2002
2108
|
if (!(htmlDir && htmlPagesPath))
|
|
2003
2109
|
return;
|
|
2004
|
-
const outputHtmlPages = isSingle ?
|
|
2110
|
+
const outputHtmlPages = isSingle ? join6(buildPath, "pages") : join6(buildPath, basename4(htmlDir), "pages");
|
|
2005
2111
|
if (shouldCopyHtml) {
|
|
2006
|
-
|
|
2112
|
+
mkdirSync2(outputHtmlPages, { recursive: true });
|
|
2007
2113
|
cpSync(htmlPagesPath, outputHtmlPages, {
|
|
2008
2114
|
force: true,
|
|
2009
2115
|
recursive: true
|
|
@@ -2023,21 +2129,21 @@ var build2 = async ({
|
|
|
2023
2129
|
(async () => {
|
|
2024
2130
|
if (!(htmxDir && htmxPagesPath))
|
|
2025
2131
|
return;
|
|
2026
|
-
const outputHtmxPages = isSingle ?
|
|
2132
|
+
const outputHtmxPages = isSingle ? join6(buildPath, "pages") : join6(buildPath, basename4(htmxDir), "pages");
|
|
2027
2133
|
if (shouldCopyHtmx) {
|
|
2028
|
-
|
|
2134
|
+
mkdirSync2(outputHtmxPages, { recursive: true });
|
|
2029
2135
|
cpSync(htmxPagesPath, outputHtmxPages, {
|
|
2030
2136
|
force: true,
|
|
2031
2137
|
recursive: true
|
|
2032
2138
|
});
|
|
2033
2139
|
}
|
|
2034
2140
|
if (shouldCopyHtmx) {
|
|
2035
|
-
const htmxDestDir = isSingle ? buildPath :
|
|
2036
|
-
|
|
2141
|
+
const htmxDestDir = isSingle ? buildPath : join6(buildPath, basename4(htmxDir));
|
|
2142
|
+
mkdirSync2(htmxDestDir, { recursive: true });
|
|
2037
2143
|
const glob = new Glob3("htmx*.min.js");
|
|
2038
2144
|
for (const relPath of glob.scanSync({ cwd: htmxDir })) {
|
|
2039
|
-
const src =
|
|
2040
|
-
const dest =
|
|
2145
|
+
const src = join6(htmxDir, relPath);
|
|
2146
|
+
const dest = join6(htmxDestDir, "htmx.min.js");
|
|
2041
2147
|
copyFileSync(src, dest);
|
|
2042
2148
|
break;
|
|
2043
2149
|
}
|
|
@@ -2063,16 +2169,20 @@ var build2 = async ({
|
|
|
2063
2169
|
if (!isIncremental && !options?.injectHMR) {
|
|
2064
2170
|
console.log(`Build completed in ${getDurationString(performance.now() - buildStart)}`);
|
|
2065
2171
|
}
|
|
2172
|
+
sendTelemetryEvent("build:complete", {
|
|
2173
|
+
frameworks: frameworkNames,
|
|
2174
|
+
durationMs: Math.round(performance.now() - buildStart)
|
|
2175
|
+
});
|
|
2066
2176
|
return manifest;
|
|
2067
2177
|
};
|
|
2068
2178
|
// src/core/devBuild.ts
|
|
2069
2179
|
import { readdir as readdir2 } from "fs/promises";
|
|
2070
2180
|
import { statSync } from "fs";
|
|
2071
|
-
import { resolve as
|
|
2181
|
+
import { resolve as resolve19 } from "path";
|
|
2072
2182
|
|
|
2073
2183
|
// src/build/buildReactVendor.ts
|
|
2074
|
-
import { mkdirSync as
|
|
2075
|
-
import { join as
|
|
2184
|
+
import { mkdirSync as mkdirSync3 } from "fs";
|
|
2185
|
+
import { join as join7 } from "path";
|
|
2076
2186
|
import { rm as rm4 } from "fs/promises";
|
|
2077
2187
|
var {build: bunBuild3 } = globalThis.Bun;
|
|
2078
2188
|
var reactSpecifiers = [
|
|
@@ -2105,14 +2215,14 @@ var generateEntrySource = async (specifier) => {
|
|
|
2105
2215
|
`;
|
|
2106
2216
|
};
|
|
2107
2217
|
var buildReactVendor = async (buildDir) => {
|
|
2108
|
-
const vendorDir =
|
|
2109
|
-
|
|
2110
|
-
const tmpDir =
|
|
2111
|
-
|
|
2218
|
+
const vendorDir = join7(buildDir, "react", "vendor");
|
|
2219
|
+
mkdirSync3(vendorDir, { recursive: true });
|
|
2220
|
+
const tmpDir = join7(buildDir, "_vendor_tmp");
|
|
2221
|
+
mkdirSync3(tmpDir, { recursive: true });
|
|
2112
2222
|
const entrypoints = [];
|
|
2113
2223
|
for (const specifier of reactSpecifiers) {
|
|
2114
2224
|
const safeName = toSafeFileName(specifier);
|
|
2115
|
-
const entryPath =
|
|
2225
|
+
const entryPath = join7(tmpDir, `${safeName}.ts`);
|
|
2116
2226
|
const source = await generateEntrySource(specifier);
|
|
2117
2227
|
await Bun.write(entryPath, source);
|
|
2118
2228
|
entrypoints.push(entryPath);
|
|
@@ -2134,18 +2244,18 @@ var buildReactVendor = async (buildDir) => {
|
|
|
2134
2244
|
};
|
|
2135
2245
|
|
|
2136
2246
|
// src/dev/dependencyGraph.ts
|
|
2137
|
-
import { readFileSync as
|
|
2138
|
-
import { resolve as
|
|
2247
|
+
import { readFileSync as readFileSync4, readdirSync, existsSync as existsSync6 } from "fs";
|
|
2248
|
+
import { resolve as resolve8 } from "path";
|
|
2139
2249
|
var createDependencyGraph = () => ({
|
|
2140
2250
|
dependencies: new Map,
|
|
2141
2251
|
dependents: new Map
|
|
2142
2252
|
});
|
|
2143
2253
|
var extractDependencies = (filePath) => {
|
|
2144
2254
|
try {
|
|
2145
|
-
if (!
|
|
2255
|
+
if (!existsSync6(filePath)) {
|
|
2146
2256
|
return [];
|
|
2147
2257
|
}
|
|
2148
|
-
const content =
|
|
2258
|
+
const content = readFileSync4(filePath, "utf-8");
|
|
2149
2259
|
const dependencies = [];
|
|
2150
2260
|
const lowerPath = filePath.toLowerCase();
|
|
2151
2261
|
const isHtml = lowerPath.endsWith(".html") || lowerPath.endsWith(".htm");
|
|
@@ -2205,9 +2315,9 @@ var resolveImportPath = (importPath, fromFile) => {
|
|
|
2205
2315
|
if (!importPath.startsWith(".") && !importPath.startsWith("/")) {
|
|
2206
2316
|
return null;
|
|
2207
2317
|
}
|
|
2208
|
-
const fromDir =
|
|
2209
|
-
const resolved =
|
|
2210
|
-
const normalized =
|
|
2318
|
+
const fromDir = resolve8(fromFile, "..");
|
|
2319
|
+
const resolved = resolve8(fromDir, importPath);
|
|
2320
|
+
const normalized = resolve8(resolved);
|
|
2211
2321
|
const extensions = [
|
|
2212
2322
|
".ts",
|
|
2213
2323
|
".tsx",
|
|
@@ -2221,20 +2331,20 @@ var resolveImportPath = (importPath, fromFile) => {
|
|
|
2221
2331
|
for (const ext of extensions) {
|
|
2222
2332
|
const withExt = normalized + ext;
|
|
2223
2333
|
try {
|
|
2224
|
-
|
|
2334
|
+
readFileSync4(withExt);
|
|
2225
2335
|
return normalized + ext;
|
|
2226
2336
|
} catch {}
|
|
2227
2337
|
}
|
|
2228
2338
|
try {
|
|
2229
|
-
|
|
2339
|
+
readFileSync4(normalized);
|
|
2230
2340
|
return normalized;
|
|
2231
2341
|
} catch {
|
|
2232
2342
|
return null;
|
|
2233
2343
|
}
|
|
2234
2344
|
};
|
|
2235
2345
|
var addFileToGraph = (graph, filePath) => {
|
|
2236
|
-
const normalizedPath =
|
|
2237
|
-
if (!
|
|
2346
|
+
const normalizedPath = resolve8(filePath);
|
|
2347
|
+
if (!existsSync6(normalizedPath)) {
|
|
2238
2348
|
return;
|
|
2239
2349
|
}
|
|
2240
2350
|
const dependencies = extractDependencies(normalizedPath);
|
|
@@ -2257,7 +2367,7 @@ var addFileToGraph = (graph, filePath) => {
|
|
|
2257
2367
|
}
|
|
2258
2368
|
};
|
|
2259
2369
|
var getAffectedFiles = (graph, changedFile) => {
|
|
2260
|
-
const normalizedPath =
|
|
2370
|
+
const normalizedPath = resolve8(changedFile);
|
|
2261
2371
|
const affected = new Set;
|
|
2262
2372
|
const toProcess = [normalizedPath];
|
|
2263
2373
|
while (toProcess.length > 0) {
|
|
@@ -2276,7 +2386,7 @@ var getAffectedFiles = (graph, changedFile) => {
|
|
|
2276
2386
|
return Array.from(affected);
|
|
2277
2387
|
};
|
|
2278
2388
|
var removeFileFromGraph = (graph, filePath) => {
|
|
2279
|
-
const normalizedPath =
|
|
2389
|
+
const normalizedPath = resolve8(filePath);
|
|
2280
2390
|
const deps = graph.dependencies.get(normalizedPath);
|
|
2281
2391
|
if (deps) {
|
|
2282
2392
|
for (const dep of deps) {
|
|
@@ -2301,11 +2411,11 @@ var removeFileFromGraph = (graph, filePath) => {
|
|
|
2301
2411
|
var buildInitialDependencyGraph = (graph, directories) => {
|
|
2302
2412
|
const processedFiles = new Set;
|
|
2303
2413
|
const scanDirectory = (dir) => {
|
|
2304
|
-
const normalizedDir =
|
|
2414
|
+
const normalizedDir = resolve8(dir);
|
|
2305
2415
|
try {
|
|
2306
2416
|
const entries = readdirSync(normalizedDir, { withFileTypes: true });
|
|
2307
2417
|
for (const entry of entries) {
|
|
2308
|
-
const fullPath =
|
|
2418
|
+
const fullPath = resolve8(normalizedDir, entry.name);
|
|
2309
2419
|
if (fullPath.includes("/node_modules/") || fullPath.includes("/.git/") || fullPath.includes("/build/") || fullPath.includes("/compiled/") || fullPath.includes("/indexes/") || entry.name.startsWith(".")) {
|
|
2310
2420
|
continue;
|
|
2311
2421
|
}
|
|
@@ -2333,8 +2443,8 @@ var buildInitialDependencyGraph = (graph, directories) => {
|
|
|
2333
2443
|
} catch {}
|
|
2334
2444
|
};
|
|
2335
2445
|
for (const dir of directories) {
|
|
2336
|
-
const resolvedDir =
|
|
2337
|
-
if (
|
|
2446
|
+
const resolvedDir = resolve8(dir);
|
|
2447
|
+
if (existsSync6(resolvedDir)) {
|
|
2338
2448
|
scanDirectory(resolvedDir);
|
|
2339
2449
|
}
|
|
2340
2450
|
}
|
|
@@ -2366,12 +2476,12 @@ var serializeModuleVersions = (versions) => {
|
|
|
2366
2476
|
};
|
|
2367
2477
|
|
|
2368
2478
|
// src/dev/configResolver.ts
|
|
2369
|
-
import { resolve as
|
|
2479
|
+
import { resolve as resolve9 } from "path";
|
|
2370
2480
|
var resolveBuildPaths = (config) => {
|
|
2371
2481
|
const cwd2 = process.cwd();
|
|
2372
2482
|
const normalize = (path) => path.replace(/\\/g, "/");
|
|
2373
|
-
const withDefault = (value, fallback) => normalize(
|
|
2374
|
-
const optional = (value) => value ? normalize(
|
|
2483
|
+
const withDefault = (value, fallback) => normalize(resolve9(cwd2, value ?? fallback));
|
|
2484
|
+
const optional = (value) => value ? normalize(resolve9(cwd2, value)) : undefined;
|
|
2375
2485
|
return {
|
|
2376
2486
|
buildDir: withDefault(config.buildDirectory, "build"),
|
|
2377
2487
|
assetsDir: optional(config.assetsDirectory),
|
|
@@ -2416,8 +2526,8 @@ var incrementSourceFileVersions = (state, filePaths) => {
|
|
|
2416
2526
|
|
|
2417
2527
|
// src/dev/fileWatcher.ts
|
|
2418
2528
|
import { watch } from "fs";
|
|
2419
|
-
import { existsSync as
|
|
2420
|
-
import { join as
|
|
2529
|
+
import { existsSync as existsSync7 } from "fs";
|
|
2530
|
+
import { join as join8, resolve as resolve10 } from "path";
|
|
2421
2531
|
|
|
2422
2532
|
// src/dev/pathUtils.ts
|
|
2423
2533
|
var getWatchPaths = (config, resolved) => {
|
|
@@ -2532,8 +2642,8 @@ var detectFramework = (filePath, resolved) => {
|
|
|
2532
2642
|
var startFileWatching = (state, config, onFileChange) => {
|
|
2533
2643
|
const watchPaths = getWatchPaths(config, state.resolvedPaths);
|
|
2534
2644
|
for (const path of watchPaths) {
|
|
2535
|
-
const absolutePath =
|
|
2536
|
-
if (!
|
|
2645
|
+
const absolutePath = resolve10(path).replace(/\\/g, "/");
|
|
2646
|
+
if (!existsSync7(absolutePath)) {
|
|
2537
2647
|
continue;
|
|
2538
2648
|
}
|
|
2539
2649
|
const watcher = watch(absolutePath, { recursive: true }, (event, filename) => {
|
|
@@ -2542,22 +2652,32 @@ var startFileWatching = (state, config, onFileChange) => {
|
|
|
2542
2652
|
if (filename === "compiled" || filename === "build" || filename === "indexes" || filename.includes("/compiled") || filename.includes("/build") || filename.includes("/indexes") || filename.endsWith("/")) {
|
|
2543
2653
|
return;
|
|
2544
2654
|
}
|
|
2545
|
-
const fullPath =
|
|
2655
|
+
const fullPath = join8(absolutePath, filename).replace(/\\/g, "/");
|
|
2546
2656
|
if (shouldIgnorePath(fullPath)) {
|
|
2547
2657
|
return;
|
|
2548
2658
|
}
|
|
2549
|
-
if (event === "rename" && !
|
|
2659
|
+
if (event === "rename" && !existsSync7(fullPath)) {
|
|
2550
2660
|
try {
|
|
2551
2661
|
removeFileFromGraph(state.dependencyGraph, fullPath);
|
|
2552
|
-
} catch {
|
|
2662
|
+
} catch (err) {
|
|
2663
|
+
sendTelemetryEvent("hmr:graph-error", {
|
|
2664
|
+
operation: "remove",
|
|
2665
|
+
message: err instanceof Error ? err.message : String(err)
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2553
2668
|
onFileChange(fullPath);
|
|
2554
2669
|
return;
|
|
2555
2670
|
}
|
|
2556
|
-
if (
|
|
2671
|
+
if (existsSync7(fullPath)) {
|
|
2557
2672
|
onFileChange(fullPath);
|
|
2558
2673
|
try {
|
|
2559
2674
|
addFileToGraph(state.dependencyGraph, fullPath);
|
|
2560
|
-
} catch {
|
|
2675
|
+
} catch (err) {
|
|
2676
|
+
sendTelemetryEvent("hmr:graph-error", {
|
|
2677
|
+
operation: "add",
|
|
2678
|
+
message: err instanceof Error ? err.message : String(err)
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2561
2681
|
}
|
|
2562
2682
|
});
|
|
2563
2683
|
state.watchers.push(watcher);
|
|
@@ -2565,7 +2685,7 @@ var startFileWatching = (state, config, onFileChange) => {
|
|
|
2565
2685
|
};
|
|
2566
2686
|
|
|
2567
2687
|
// src/dev/assetStore.ts
|
|
2568
|
-
import { resolve as
|
|
2688
|
+
import { resolve as resolve11 } from "path";
|
|
2569
2689
|
import { readdir, unlink } from "fs/promises";
|
|
2570
2690
|
var mimeTypes = {
|
|
2571
2691
|
".css": "text/css",
|
|
@@ -2599,7 +2719,7 @@ var populateAssetStore = async (store, manifest, buildDir) => {
|
|
|
2599
2719
|
}
|
|
2600
2720
|
}
|
|
2601
2721
|
for (const webPath of newIdentities.values()) {
|
|
2602
|
-
loadPromises.push(Bun.file(
|
|
2722
|
+
loadPromises.push(Bun.file(resolve11(buildDir, webPath.slice(1))).bytes().then((bytes) => {
|
|
2603
2723
|
store.set(webPath, bytes);
|
|
2604
2724
|
}).catch(() => {}));
|
|
2605
2725
|
}
|
|
@@ -2609,11 +2729,11 @@ var populateAssetStore = async (store, manifest, buildDir) => {
|
|
|
2609
2729
|
const subTasks = [];
|
|
2610
2730
|
for (const entry of entries) {
|
|
2611
2731
|
if (entry.isDirectory()) {
|
|
2612
|
-
subTasks.push(scanDir(
|
|
2732
|
+
subTasks.push(scanDir(resolve11(dir, entry.name), `${prefix}${entry.name}/`));
|
|
2613
2733
|
} else if (entry.name.startsWith("chunk-")) {
|
|
2614
2734
|
const webPath = `/${prefix}${entry.name}`;
|
|
2615
2735
|
if (!store.has(webPath)) {
|
|
2616
|
-
subTasks.push(Bun.file(
|
|
2736
|
+
subTasks.push(Bun.file(resolve11(dir, entry.name)).bytes().then((bytes) => {
|
|
2617
2737
|
store.set(webPath, bytes);
|
|
2618
2738
|
}).catch(() => {}));
|
|
2619
2739
|
}
|
|
@@ -2628,10 +2748,10 @@ var populateAssetStore = async (store, manifest, buildDir) => {
|
|
|
2628
2748
|
var cleanStaleAssets = async (store, manifest, buildDir) => {
|
|
2629
2749
|
const liveByIdentity = new Map;
|
|
2630
2750
|
for (const webPath of store.keys()) {
|
|
2631
|
-
const diskPath =
|
|
2751
|
+
const diskPath = resolve11(buildDir, webPath.slice(1));
|
|
2632
2752
|
liveByIdentity.set(stripHash(diskPath), diskPath);
|
|
2633
2753
|
}
|
|
2634
|
-
const absBuildDir =
|
|
2754
|
+
const absBuildDir = resolve11(buildDir);
|
|
2635
2755
|
for (const val of Object.values(manifest)) {
|
|
2636
2756
|
if (!HASHED_FILE_RE.test(val))
|
|
2637
2757
|
continue;
|
|
@@ -2644,7 +2764,7 @@ var cleanStaleAssets = async (store, manifest, buildDir) => {
|
|
|
2644
2764
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
2645
2765
|
const tasks = [];
|
|
2646
2766
|
for (const entry of entries) {
|
|
2647
|
-
const fullPath =
|
|
2767
|
+
const fullPath = resolve11(dir, entry.name);
|
|
2648
2768
|
if (entry.isDirectory()) {
|
|
2649
2769
|
tasks.push(walkAndClean(fullPath));
|
|
2650
2770
|
} else if (HASHED_FILE_RE.test(entry.name)) {
|
|
@@ -2663,15 +2783,15 @@ var cleanStaleAssets = async (store, manifest, buildDir) => {
|
|
|
2663
2783
|
var lookupAsset = (store, path) => store.get(path);
|
|
2664
2784
|
|
|
2665
2785
|
// src/dev/rebuildTrigger.ts
|
|
2666
|
-
import { existsSync as
|
|
2667
|
-
import { basename as basename8, resolve as
|
|
2786
|
+
import { existsSync as existsSync10 } from "fs";
|
|
2787
|
+
import { basename as basename8, resolve as resolve18 } from "path";
|
|
2668
2788
|
|
|
2669
2789
|
// src/dev/fileHashTracker.ts
|
|
2670
2790
|
import { createHash } from "crypto";
|
|
2671
|
-
import { readFileSync as
|
|
2791
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
2672
2792
|
var computeFileHash = (filePath) => {
|
|
2673
2793
|
try {
|
|
2674
|
-
const fileContent =
|
|
2794
|
+
const fileContent = readFileSync5(filePath);
|
|
2675
2795
|
const hash = createHash("sha256");
|
|
2676
2796
|
hash.update(fileContent);
|
|
2677
2797
|
return hash.digest("hex");
|
|
@@ -2689,12 +2809,12 @@ var hasFileChanged = (filePath, currentHash, previousHashes) => {
|
|
|
2689
2809
|
};
|
|
2690
2810
|
|
|
2691
2811
|
// src/dev/moduleMapper.ts
|
|
2692
|
-
import { basename as basename5, resolve as
|
|
2812
|
+
import { basename as basename5, resolve as resolve13 } from "path";
|
|
2693
2813
|
|
|
2694
2814
|
// src/dev/reactComponentClassifier.ts
|
|
2695
|
-
import { resolve as
|
|
2815
|
+
import { resolve as resolve12 } from "path";
|
|
2696
2816
|
var classifyComponent = (filePath) => {
|
|
2697
|
-
const normalizedPath =
|
|
2817
|
+
const normalizedPath = resolve12(filePath);
|
|
2698
2818
|
if (normalizedPath.includes("/react/pages/")) {
|
|
2699
2819
|
return "server";
|
|
2700
2820
|
}
|
|
@@ -2706,7 +2826,7 @@ var classifyComponent = (filePath) => {
|
|
|
2706
2826
|
|
|
2707
2827
|
// src/dev/moduleMapper.ts
|
|
2708
2828
|
var mapSourceFileToManifestKeys = (sourceFile, framework, resolvedPaths) => {
|
|
2709
|
-
const normalizedFile =
|
|
2829
|
+
const normalizedFile = resolve13(sourceFile);
|
|
2710
2830
|
const fileName = basename5(normalizedFile);
|
|
2711
2831
|
const baseName = fileName.replace(/\.(tsx?|jsx?|vue|svelte|css|html)$/, "");
|
|
2712
2832
|
const pascalName = toPascal(baseName);
|
|
@@ -2759,7 +2879,7 @@ var createModuleUpdates = (changedFiles, framework, manifest, resolvedPaths) =>
|
|
|
2759
2879
|
const updates = [];
|
|
2760
2880
|
const processedFiles = new Set;
|
|
2761
2881
|
for (const sourceFile of changedFiles) {
|
|
2762
|
-
const normalizedFile =
|
|
2882
|
+
const normalizedFile = resolve13(sourceFile);
|
|
2763
2883
|
const normalizedPath = normalizedFile.replace(/\\/g, "/");
|
|
2764
2884
|
if (processedFiles.has(normalizedFile))
|
|
2765
2885
|
continue;
|
|
@@ -2851,8 +2971,6 @@ var handleHMRMessage = (state, client2, message) => {
|
|
|
2851
2971
|
break;
|
|
2852
2972
|
case "ready":
|
|
2853
2973
|
break;
|
|
2854
|
-
case "hydration-error":
|
|
2855
|
-
break;
|
|
2856
2974
|
}
|
|
2857
2975
|
} catch {}
|
|
2858
2976
|
};
|
|
@@ -2974,13 +3092,13 @@ var queueFileChange = (state, filePath, config, onRebuildComplete) => {
|
|
|
2974
3092
|
const validFiles = [];
|
|
2975
3093
|
const processedFiles = new Set;
|
|
2976
3094
|
for (const filePathInSet of filePathSet) {
|
|
2977
|
-
if (!
|
|
3095
|
+
if (!existsSync10(filePathInSet)) {
|
|
2978
3096
|
state.fileHashes.delete(filePathInSet);
|
|
2979
3097
|
try {
|
|
2980
3098
|
const affectedFiles = getAffectedFiles(state.dependencyGraph, filePathInSet);
|
|
2981
|
-
const deletedPathResolved =
|
|
3099
|
+
const deletedPathResolved = resolve18(filePathInSet);
|
|
2982
3100
|
for (const affectedFile of affectedFiles) {
|
|
2983
|
-
if (affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) &&
|
|
3101
|
+
if (affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync10(affectedFile)) {
|
|
2984
3102
|
validFiles.push(affectedFile);
|
|
2985
3103
|
processedFiles.add(affectedFile);
|
|
2986
3104
|
}
|
|
@@ -2991,7 +3109,7 @@ var queueFileChange = (state, filePath, config, onRebuildComplete) => {
|
|
|
2991
3109
|
const fileHash = computeFileHash(filePathInSet);
|
|
2992
3110
|
const storedHash = state.fileHashes.get(filePathInSet);
|
|
2993
3111
|
if (!storedHash || storedHash !== fileHash) {
|
|
2994
|
-
const normalizedFilePath =
|
|
3112
|
+
const normalizedFilePath = resolve18(filePathInSet);
|
|
2995
3113
|
if (!processedFiles.has(normalizedFilePath)) {
|
|
2996
3114
|
validFiles.push(normalizedFilePath);
|
|
2997
3115
|
processedFiles.add(normalizedFilePath);
|
|
@@ -3001,7 +3119,7 @@ var queueFileChange = (state, filePath, config, onRebuildComplete) => {
|
|
|
3001
3119
|
try {
|
|
3002
3120
|
const dependents = state.dependencyGraph.dependents.get(normalizedFilePath);
|
|
3003
3121
|
if (dependents && dependents.size > 0) {
|
|
3004
|
-
const dependentFiles = Array.from(dependents).filter((f) =>
|
|
3122
|
+
const dependentFiles = Array.from(dependents).filter((f) => existsSync10(f));
|
|
3005
3123
|
if (dependentFiles.length > 0) {
|
|
3006
3124
|
incrementSourceFileVersions(state, dependentFiles);
|
|
3007
3125
|
}
|
|
@@ -3010,7 +3128,7 @@ var queueFileChange = (state, filePath, config, onRebuildComplete) => {
|
|
|
3010
3128
|
try {
|
|
3011
3129
|
const affectedFiles = getAffectedFiles(state.dependencyGraph, normalizedFilePath);
|
|
3012
3130
|
for (const affectedFile of affectedFiles) {
|
|
3013
|
-
if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath &&
|
|
3131
|
+
if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync10(affectedFile)) {
|
|
3014
3132
|
validFiles.push(affectedFile);
|
|
3015
3133
|
processedFiles.add(affectedFile);
|
|
3016
3134
|
}
|
|
@@ -3073,6 +3191,11 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3073
3191
|
throw new Error("Build failed - no manifest generated");
|
|
3074
3192
|
}
|
|
3075
3193
|
const duration = Date.now() - startTime;
|
|
3194
|
+
sendTelemetryEvent("hmr:rebuild-complete", {
|
|
3195
|
+
framework: affectedFrameworks[0] ?? "unknown",
|
|
3196
|
+
durationMs: duration,
|
|
3197
|
+
fileCount: filesToRebuild?.length ?? 0
|
|
3198
|
+
});
|
|
3076
3199
|
await populateAssetStore(state.assetStore, manifest, state.resolvedPaths.buildDir);
|
|
3077
3200
|
await cleanStaleAssets(state.assetStore, manifest, state.resolvedPaths.buildDir);
|
|
3078
3201
|
broadcastToClients(state, {
|
|
@@ -3122,7 +3245,12 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3122
3245
|
},
|
|
3123
3246
|
type: "react-update"
|
|
3124
3247
|
});
|
|
3125
|
-
} catch {
|
|
3248
|
+
} catch (err) {
|
|
3249
|
+
sendTelemetryEvent("hmr:error", {
|
|
3250
|
+
framework: "react",
|
|
3251
|
+
message: err instanceof Error ? err.message : String(err)
|
|
3252
|
+
});
|
|
3253
|
+
}
|
|
3126
3254
|
}
|
|
3127
3255
|
}
|
|
3128
3256
|
if (affectedFrameworks.includes("html") && filesToRebuild && state.resolvedPaths.htmlDir) {
|
|
@@ -3162,10 +3290,10 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3162
3290
|
const htmlPageFiles = htmlFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
3163
3291
|
const pagesToUpdate = htmlPageFiles;
|
|
3164
3292
|
const isSingle = !config.reactDirectory && !config.svelteDirectory && !config.vueDirectory && !config.htmxDirectory;
|
|
3165
|
-
const outputHtmlPages = isSingle ?
|
|
3293
|
+
const outputHtmlPages = isSingle ? resolve18(state.resolvedPaths.buildDir, "pages") : resolve18(state.resolvedPaths.buildDir, basename8(config.htmlDirectory ?? "html"), "pages");
|
|
3166
3294
|
for (const pageFile of pagesToUpdate) {
|
|
3167
3295
|
const htmlPageName = basename8(pageFile);
|
|
3168
|
-
const builtHtmlPagePath =
|
|
3296
|
+
const builtHtmlPagePath = resolve18(outputHtmlPages, htmlPageName);
|
|
3169
3297
|
try {
|
|
3170
3298
|
const { handleHTMLUpdate: handleHTMLUpdate2 } = await Promise.resolve().then(() => (init_simpleHTMLHMR(), exports_simpleHTMLHMR));
|
|
3171
3299
|
const newHTML = await handleHTMLUpdate2(builtHtmlPagePath);
|
|
@@ -3180,7 +3308,12 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3180
3308
|
type: "html-update"
|
|
3181
3309
|
});
|
|
3182
3310
|
}
|
|
3183
|
-
} catch {
|
|
3311
|
+
} catch (err) {
|
|
3312
|
+
sendTelemetryEvent("hmr:error", {
|
|
3313
|
+
framework: "html",
|
|
3314
|
+
message: err instanceof Error ? err.message : String(err)
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3184
3317
|
}
|
|
3185
3318
|
}
|
|
3186
3319
|
}
|
|
@@ -3227,7 +3360,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3227
3360
|
const cssKey = `${pascalName}CSS`;
|
|
3228
3361
|
const cssUrl = manifest[cssKey] || null;
|
|
3229
3362
|
const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
|
|
3230
|
-
const hmrMeta = vueHmrMetadata2.get(
|
|
3363
|
+
const hmrMeta = vueHmrMetadata2.get(resolve18(vuePagePath));
|
|
3231
3364
|
const changeType = hmrMeta?.changeType ?? "full";
|
|
3232
3365
|
if (changeType === "style-only") {
|
|
3233
3366
|
logger.cssUpdate(vuePagePath, "vue", duration);
|
|
@@ -3264,7 +3397,12 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3264
3397
|
},
|
|
3265
3398
|
type: "vue-update"
|
|
3266
3399
|
});
|
|
3267
|
-
} catch {
|
|
3400
|
+
} catch (err) {
|
|
3401
|
+
sendTelemetryEvent("hmr:error", {
|
|
3402
|
+
framework: "vue",
|
|
3403
|
+
message: err instanceof Error ? err.message : String(err)
|
|
3404
|
+
});
|
|
3405
|
+
}
|
|
3268
3406
|
}
|
|
3269
3407
|
}
|
|
3270
3408
|
}
|
|
@@ -3323,7 +3461,12 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3323
3461
|
},
|
|
3324
3462
|
type: "svelte-update"
|
|
3325
3463
|
});
|
|
3326
|
-
} catch {
|
|
3464
|
+
} catch (err) {
|
|
3465
|
+
sendTelemetryEvent("hmr:error", {
|
|
3466
|
+
framework: "svelte",
|
|
3467
|
+
message: err instanceof Error ? err.message : String(err)
|
|
3468
|
+
});
|
|
3469
|
+
}
|
|
3327
3470
|
}
|
|
3328
3471
|
}
|
|
3329
3472
|
}
|
|
@@ -3361,10 +3504,10 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3361
3504
|
if (htmxFrameworkFiles.length > 0) {
|
|
3362
3505
|
const htmxPageFiles = htmxFrameworkFiles.filter((f) => f.endsWith(".html"));
|
|
3363
3506
|
const isSingle = !config.reactDirectory && !config.svelteDirectory && !config.vueDirectory && !config.htmlDirectory;
|
|
3364
|
-
const outputHtmxPages = isSingle ?
|
|
3507
|
+
const outputHtmxPages = isSingle ? resolve18(state.resolvedPaths.buildDir, "pages") : resolve18(state.resolvedPaths.buildDir, basename8(config.htmxDirectory ?? "htmx"), "pages");
|
|
3365
3508
|
for (const htmxPageFile of htmxPageFiles) {
|
|
3366
3509
|
const htmxPageName = basename8(htmxPageFile);
|
|
3367
|
-
const builtHtmxPagePath =
|
|
3510
|
+
const builtHtmxPagePath = resolve18(outputHtmxPages, htmxPageName);
|
|
3368
3511
|
try {
|
|
3369
3512
|
const { handleHTMXUpdate: handleHTMXUpdate2 } = await Promise.resolve().then(() => (init_simpleHTMXHMR(), exports_simpleHTMXHMR));
|
|
3370
3513
|
const newHTML = await handleHTMXUpdate2(builtHtmxPagePath);
|
|
@@ -3379,7 +3522,12 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3379
3522
|
type: "htmx-update"
|
|
3380
3523
|
});
|
|
3381
3524
|
}
|
|
3382
|
-
} catch {
|
|
3525
|
+
} catch (err) {
|
|
3526
|
+
sendTelemetryEvent("hmr:error", {
|
|
3527
|
+
framework: "htmx",
|
|
3528
|
+
message: err instanceof Error ? err.message : String(err)
|
|
3529
|
+
});
|
|
3530
|
+
}
|
|
3383
3531
|
}
|
|
3384
3532
|
}
|
|
3385
3533
|
}
|
|
@@ -3443,6 +3591,13 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3443
3591
|
onRebuildComplete({ manifest, hmrState: state });
|
|
3444
3592
|
return manifest;
|
|
3445
3593
|
} catch (error) {
|
|
3594
|
+
sendTelemetryEvent("hmr:rebuild-error", {
|
|
3595
|
+
framework: affectedFrameworks[0] ?? "unknown",
|
|
3596
|
+
frameworks: affectedFrameworks,
|
|
3597
|
+
message: error instanceof Error ? error.message : String(error),
|
|
3598
|
+
fileCount: filesToRebuild?.length ?? 0,
|
|
3599
|
+
durationMs: Date.now() - startTime
|
|
3600
|
+
});
|
|
3446
3601
|
const errorData = extractBuildErrorDetails(error, affectedFrameworks, state.resolvedPaths);
|
|
3447
3602
|
broadcastToClients(state, {
|
|
3448
3603
|
data: {
|
|
@@ -3478,7 +3633,7 @@ var triggerRebuild = async (state, config, onRebuildComplete, filesToRebuild) =>
|
|
|
3478
3633
|
var devBuild = async (config) => {
|
|
3479
3634
|
const cached = globalThis.__hmrDevResult;
|
|
3480
3635
|
if (cached) {
|
|
3481
|
-
const serverMtime = statSync(
|
|
3636
|
+
const serverMtime = statSync(resolve19(Bun.main)).mtimeMs;
|
|
3482
3637
|
const lastMtime = globalThis.__hmrServerMtime;
|
|
3483
3638
|
globalThis.__hmrServerMtime = serverMtime;
|
|
3484
3639
|
if (serverMtime !== lastMtime) {
|
|
@@ -3495,8 +3650,8 @@ var devBuild = async (config) => {
|
|
|
3495
3650
|
setDevVendorPaths(computeVendorPaths());
|
|
3496
3651
|
}
|
|
3497
3652
|
const candidates = [
|
|
3498
|
-
|
|
3499
|
-
|
|
3653
|
+
resolve19(import.meta.dir, "..", "..", "package.json"),
|
|
3654
|
+
resolve19(import.meta.dir, "..", "package.json")
|
|
3500
3655
|
];
|
|
3501
3656
|
for (const candidate of candidates) {
|
|
3502
3657
|
try {
|
|
@@ -3522,12 +3677,12 @@ var devBuild = async (config) => {
|
|
|
3522
3677
|
await cleanStaleAssets(state.assetStore, manifest ?? {}, state.resolvedPaths.buildDir);
|
|
3523
3678
|
if (config.reactDirectory) {
|
|
3524
3679
|
await buildReactVendor(state.resolvedPaths.buildDir);
|
|
3525
|
-
const vendorDir =
|
|
3680
|
+
const vendorDir = resolve19(state.resolvedPaths.buildDir, "react", "vendor");
|
|
3526
3681
|
try {
|
|
3527
3682
|
const entries = await readdir2(vendorDir);
|
|
3528
3683
|
for (const entry of entries) {
|
|
3529
3684
|
const webPath = `/react/vendor/${entry}`;
|
|
3530
|
-
const bytes = await Bun.file(
|
|
3685
|
+
const bytes = await Bun.file(resolve19(vendorDir, entry)).bytes();
|
|
3531
3686
|
state.assetStore.set(webPath, bytes);
|
|
3532
3687
|
}
|
|
3533
3688
|
} catch {}
|
|
@@ -3543,7 +3698,7 @@ var devBuild = async (config) => {
|
|
|
3543
3698
|
manifest
|
|
3544
3699
|
};
|
|
3545
3700
|
globalThis.__hmrDevResult = result;
|
|
3546
|
-
globalThis.__hmrServerMtime = statSync(
|
|
3701
|
+
globalThis.__hmrServerMtime = statSync(resolve19(Bun.main)).mtimeMs;
|
|
3547
3702
|
return result;
|
|
3548
3703
|
};
|
|
3549
3704
|
// src/core/lookup.ts
|
|
@@ -3816,5 +3971,5 @@ export {
|
|
|
3816
3971
|
BUN_BUILD_WARNING_SUPPRESSION
|
|
3817
3972
|
};
|
|
3818
3973
|
|
|
3819
|
-
//# debugId=
|
|
3974
|
+
//# debugId=6ECBDD8CC34387CC64756E2164756E21
|
|
3820
3975
|
//# sourceMappingURL=index.js.map
|