From a09b99565138bb4bc73a5328397428fb5025817b Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Wed, 19 Jan 2022 23:07:03 -0800 Subject: Bun.Transpiler – API for scanning imports/exports of JSX/TSX/TS/JS files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bench/snippets/scanner/scan.bun.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bench/snippets/scanner/scan.bun.js (limited to 'bench/snippets/scanner/scan.bun.js') diff --git a/bench/snippets/scanner/scan.bun.js b/bench/snippets/scanner/scan.bun.js new file mode 100644 index 000000000..7a34f056e --- /dev/null +++ b/bench/snippets/scanner/scan.bun.js @@ -0,0 +1,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"); -- cgit v1.2.3