Skip to content

Commit 6b12f93

Browse files
committed
q
1 parent 96b33e0 commit 6b12f93

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

transpile.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,23 @@ const options: esbuild.BuildOptions = {
5858
format: "esm",
5959
target: "node20",
6060
logLevel: "warning",
61+
metafile: true,
6162
logOverride: {
6263
"direct-eval": "silent",
6364
},
6465
plugins: [
6566
{
6667
name: "watch-reporter",
6768
setup(build) {
68-
const mtimes = new Map<string, number>();
69-
let isInitialBuild = true;
7069
build.onEnd((result) => {
71-
if (result.errors.length > 0) return;
72-
const changed: string[] = [];
73-
for (const ep of entryPoints) {
74-
try {
75-
const stats = fs.statSync(ep);
76-
const lastMtime = mtimes.get(ep);
77-
if (lastMtime !== undefined && stats.mtimeMs > lastMtime) {
78-
changed.push(ep);
79-
}
80-
mtimes.set(ep, stats.mtimeMs);
81-
} catch (e) {}
70+
if (result.errors.length > 0 || !result.metafile) return;
71+
const entryPoints = new Set<string>();
72+
for (const info of Object.values(result.metafile.outputs)) {
73+
if (info.entryPoint) {
74+
entryPoints.add(info.entryPoint);
75+
}
8276
}
83-
changed.forEach((file) => console.log(`transpiled ${file}`));
84-
isInitialBuild = false;
77+
entryPoints.forEach((file) => console.log(`transpiled ${file}`));
8578
});
8679
},
8780
},

transpile_pipe.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ Description:
4040

4141
const BATCH_SIZE = 3;
4242
const DEBOUNCE_MS = 100;
43+
const PADDING = 4;
4344

45+
let counter = 0;
4446
let buffer: string[] = [];
4547
let timeout: NodeJS.Timeout | null = null;
4648

@@ -71,7 +73,11 @@ function flush() {
7173
console.error(`stderr: ${stderr}`);
7274
return;
7375
}
74-
files.forEach((f) => console.log(`frmtd: ${f}`));
76+
counter++;
77+
const c = String(counter).padStart(PADDING, "0");
78+
files.forEach((f) => {
79+
console.log(`frmtd: ${c} ${f}`);
80+
});
7581
});
7682
}
7783

0 commit comments

Comments
 (0)