Skip to content

Commit faca827

Browse files
committed
build(perf): avoid Bun type dependency
Keep the fixture generator dependency-free by declaring its small Bun API surface locally.\n\nRemove the Bun type package and restore the package TypeScript configuration so\npublishing the fixture generator does not expand package dependencies.
1 parent 01efc02 commit faca827

5 files changed

Lines changed: 18 additions & 22 deletions

File tree

‎apps/ccusage/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"prepack": "pnpm run build"
2828
},
2929
"devDependencies": {
30-
"@types/bun": "latest",
3130
"@types/node": "catalog:types",
3231
"publint": "catalog:lint"
3332
},
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
declare namespace Bun {
2+
interface FileSink {
3+
write(data: string): Promise<number>;
4+
end(): Promise<void>;
5+
}
6+
7+
interface BunFile {
8+
writer(): FileSink;
9+
}
10+
}
11+
12+
declare const Bun: {
13+
file(path: string): Bun.BunFile;
14+
$(strings: TemplateStringsArray, ...values: readonly unknown[]): Promise<unknown>;
15+
};

‎apps/ccusage/scripts/generate-large-fixture.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
/*
33
#! nix shell --inputs-from ../../.. nixpkgs#bun -c bun
44
*/
5-
import { $ } from 'bun';
65
import { dirname, join, resolve } from 'node:path';
76

87
const MIB = 1024 * 1024;
@@ -190,7 +189,7 @@ async function generateFixture(
190189
format === 'claude' ? '--output-dir' : '--codex-output-dir',
191190
);
192191
const fileSizeTargets = createFileSizeTargets(sizeMib * MIB);
193-
await $`rm -rf ${directory}`;
192+
await Bun.$`rm -rf ${directory}`;
194193

195194
let totalBytes = 0;
196195
let lineIndex = 0;
@@ -205,7 +204,7 @@ async function generateFixture(
205204
format === 'claude'
206205
? join(directory, 'projects', projectName, `${sessionId}.jsonl`)
207206
: join(directory, 'sessions', projectName, `${sessionId}.jsonl`);
208-
await $`mkdir -p ${dirname(filePath)}`;
207+
await Bun.$`mkdir -p ${dirname(filePath)}`;
209208

210209
const writer = Bun.file(filePath).writer();
211210
let fileBytes = 0;

‎apps/ccusage/tsconfig.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// Bundler mode
1010
"moduleResolution": "bundler",
1111
"resolveJsonModule": true,
12-
"types": ["bun", "node"],
12+
"types": ["node"],
1313
"allowImportingTsExtensions": true,
1414
"allowJs": true,
1515
// Best practices

‎pnpm-lock.yaml‎

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)