aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/scanner/scan.bun.js
blob: 7a34f056e6dda2f30cf62e223ed6761bc0fc6fa8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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");

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

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

console.timeEnd("Get exports");