aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/scanner/scan.bun.js
blob: eb2b0945224f9d02ccd2dd7c165fc2a08c4344f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { readFileSync } from "fs";
const fixture = ["action", "default", "loader"];
const ITERATIONS = parseInt(process.env.ITERATIONS || "1") || 1;

const transpiler = new Bun.Transpiler({
  loader: "ts",
});

console.time("Get exports");
const file = readFileSync("remix-route.ts", "utf8");
for (let i = 0; i < ITERATIONS; i++) {
  const { imports, exports } = transpiler.scan(file);

  for (let j = 0; j < fixture.length; j++) {
    if (fixture[j] !== exports[j]) {
      throw new Error("Mismatch");
    }
  }
}

console.timeEnd("Get exports");