Skip to content

Commit 282522e

Browse files
committed
chore: drop require in benchmark
In latest node, tsx/node seem to load this benchmark file as ESM which results in an error when trying to use `require.resolve`. We can achieve the same with regular path resolution, using `import.meta` to get hold of the current path.
1 parent 73479f9 commit 282522e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

benchmark/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair -- ignore
22
/* eslint-disable no-console -- ignore */
3-
import * as Benchmark from "benchmark";
3+
import Benchmark from "benchmark";
44
import fs from "fs";
55
import { parseForESLint } from "../src/index.js";
66
import { parseForESLint as parseOld } from "../node_modules/svelte-eslint-parser/lib/index.js";
7+
import { fileURLToPath } from "node:url";
8+
import path from "node:path";
79

10+
const dirname = fileURLToPath(new URL(".", import.meta.url));
811
const contents = `${fs.readFileSync(
9-
require.resolve("../explorer-v2/src/lib/RulesSettings.svelte"),
12+
path.resolve(dirname, "../explorer-v2/src/lib/RulesSettings.svelte"),
1013
"utf-8",
1114
)}// comments`;
1215

0 commit comments

Comments
 (0)