Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions benchmark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { bench, run } from "mitata";

// Dummy data generator
const generateData = (count: number) => {
return Array.from({ length: count }, (_, i) => ({
id: i,
name: `Item ${i}`,
deps: i % 2 === 0 ? { 'foo': 'bar' } : null,
}));
};

const smallData = generateData(10);
const mediumData = generateData(100);
const largeData = generateData(10000);

bench("Filter + Map (Small)", () => {
smallData
.filter((v) => !!v.deps)
.map((v) => ({
key: `v_${v.id}`,
label: v.name,
}));
});

bench("Reduce (Small)", () => {
smallData.reduce((acc, v) => {
if (v.deps) {
acc.push({
key: `v_${v.id}`,
label: v.name,
});
}
return acc;
}, [] as any[]);
});

bench("FlatMap (Small)", () => {
smallData.flatMap((v) =>
v.deps
? [
{
key: `v_${v.id}`,
label: v.name,
},
]
: []
);
});

bench("Filter + Map (Medium)", () => {
mediumData
.filter((v) => !!v.deps)
.map((v) => ({
key: `v_${v.id}`,
label: v.name,
}));
});

bench("Reduce (Medium)", () => {
mediumData.reduce((acc, v) => {
if (v.deps) {
acc.push({
key: `v_${v.id}`,
label: v.name,
});
}
return acc;
}, [] as any[]);
});

bench("FlatMap (Medium)", () => {
mediumData.flatMap((v) =>
v.deps
? [
{
key: `v_${v.id}`,
label: v.name,
},
]
: []
);
});

bench("Filter + Map (Large)", () => {
largeData
.filter((v) => !!v.deps)
.map((v) => ({
key: `v_${v.id}`,
label: v.name,
}));
});

bench("Reduce (Large)", () => {
largeData.reduce((acc, v) => {
if (v.deps) {
acc.push({
key: `v_${v.id}`,
label: v.name,
});
}
return acc;
}, [] as any[]);
});

bench("FlatMap (Large)", () => {
largeData.flatMap((v) =>
v.deps
? [
{
key: `v_${v.id}`,
label: v.name,
},
]
: []
);
});

await run();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Check tsconfig for module/target settings supporting top-level await
cat tsconfig.json 2>/dev/null | jq '{module: .compilerOptions.module, target: .compilerOptions.target, moduleResolution: .compilerOptions.moduleResolution}' || echo "tsconfig.json not found at root"

Repository: reactnativecn/pushy-admin

Length of output: 135


🏁 Script executed:

# Also examine the benchmark.ts file around line 118 to confirm top-level await
head -130 benchmark.ts | tail -20

Repository: reactnativecn/pushy-admin

Length of output: 331


🏁 Script executed:

# Check if benchmark.ts is likely an ES module (has .ts extension, check for imports/exports)
head -20 benchmark.ts

Repository: reactnativecn/pushy-admin

Length of output: 554


🏁 Script executed:

cat package.json | jq '{type: .type, scripts: .scripts}' 2>/dev/null || cat package.json | head -30

Repository: reactnativecn/pushy-admin

Length of output: 374


🏁 Script executed:

# Also check if there are other tsconfig files or if this is a monorepo
ls -la | grep -i tsconfig

Repository: reactnativecn/pushy-admin

Length of output: 133


🏁 Script executed:

cat tsconfig.json

Repository: reactnativecn/pushy-admin

Length of output: 345


🏁 Script executed:

# Check if there's an rsbuild config that might override tsconfig settings
ls -la | grep -E "rsbuild|vite|webpack|build"

Repository: reactnativecn/pushy-admin

Length of output: 137


🏁 Script executed:

cat rsbuild.config.ts

Repository: reactnativecn/pushy-admin

Length of output: 529


🏁 Script executed:

# Also check how benchmark.ts is executed - is it in a special context?
grep -r "benchmark" package.json tsconfig.json rsbuild.config.ts 2>/dev/null | head -10

Repository: reactnativecn/pushy-admin

Length of output: 51


🏁 Script executed:

# Find where benchmark.ts is located and check context
find . -name "benchmark.ts" -type f

Repository: reactnativecn/pushy-admin

Length of output: 83


🏁 Script executed:

# Check if there are any scripts or documentation about running benchmarks
find . -type f \( -name "*.md" -o -name "*.sh" \) | xargs grep -l "benchmark" 2>/dev/null | head -5

Repository: reactnativecn/pushy-admin

Length of output: 51


🏁 Script executed:

# Check the root directory to understand how benchmark.ts is meant to be executed
ls -la | head -20

Repository: reactnativecn/pushy-admin

Length of output: 1114


🏁 Script executed:

# Check if there are any npm scripts that run benchmark.ts or if it's documented
grep -r "benchmark" . --include="*.json" --include="*.md" 2>/dev/null

Repository: reactnativecn/pushy-admin

Length of output: 51


🏁 Script executed:

# Check mitata package to understand its requirements
cat package.json | jq '.devDependencies, .dependencies' | grep -A 5 -B 5 "mitata"

Repository: reactnativecn/pushy-admin

Length of output: 339


Add explicit module and target settings to tsconfig.json to support top-level await.

The current tsconfig.json lacks explicit "module" and "target" settings, which default to "commonjs" and "ES3" respectively. These defaults do not support top-level await. Add "module": "ESNext" and "target": "ES2017" (or higher) to tsconfig.json to properly support this syntax.

Note: While the project uses Bun (which natively supports top-level await), explicit configuration ensures compatibility when running with Node.js or standard TypeScript tooling.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@benchmark.ts` at line 118, The build fails for top-level await (used where
benchmark.ts calls await run()) because tsconfig.json lacks explicit
module/target settings; update tsconfig.json to set "module": "ESNext" and
"target": "ES2017" (or higher) so TypeScript and Node tooling support top-level
await—add these entries to the compilerOptions section and recompile.

4 changes: 3 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@types/react": "^19",
"@types/react-dom": "^19",
"@types/react-router-dom": "^5.3.3",
"mitata": "^1.0.34",
"tailwindcss": "^4.2.1",
"typescript": "^5.9.3"
},
Expand Down
36 changes: 24 additions & 12 deletions src/pages/manage/components/deps-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,35 @@ export const DepsTable = ({
key: 'package',
type: 'group',
label: '原生包',
children: packages
.filter((p) => !!p.deps)
.map((p) => ({
key: `p_${p.id}`,
label: p.name,
})),
children: packages.reduce(
(acc, p) => {
if (p.deps) {
acc.push({
key: `p_${p.id}`,
label: p.name,
});
}
return acc;
},
[] as { key: string; label: string }[],
),
},
{
key: 'version',
type: 'group',
label: '热更包',
children: versions
.filter((v) => !!v.deps)
.map((v) => ({
key: `v_${v.id}`,
label: v.name,
})),
children: versions.reduce(
(acc, v) => {
if (v.deps) {
acc.push({
key: `v_${v.id}`,
label: v.name,
});
}
return acc;
},
[] as { key: string; label: string }[],
),
},
],
onClick: ({ key }) => {
Expand Down