From d9c996e72098cb5ebcd8014ee05d2997e0c9c9cc Mon Sep 17 00:00:00 2001 From: Frederik Wessberg Date: Sun, 29 May 2022 21:56:01 +0200 Subject: [PATCH] fix: don't use import assertions to ensure compatibility with Node 14 and 16 in the test runner --- test/util/ts-macro.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/util/ts-macro.ts b/test/util/ts-macro.ts index 58c1849..bfaad94 100644 --- a/test/util/ts-macro.ts +++ b/test/util/ts-macro.ts @@ -1,8 +1,13 @@ import semver from "semver"; -import pkg from "../../package.json" assert {type: "json"}; +import fs from "fs"; +import path from "crosspath"; import type {ExecutionContext, OneOrMoreMacros, Macro} from "ava"; import type {TS} from "../../src/type/ts.js"; +const currentFile = import.meta.url.replace(/file:\/{2,3}/, ""); +const currentDir = path.dirname(currentFile); +const pkg = JSON.parse(fs.readFileSync(path.join(currentDir, "../../package.json"), "utf-8")); + // ava macros export interface ExtendedImplementationArgumentOptions { typescript: typeof TS;