diff --git a/packages/babel-core/test/errors-stacks.js b/packages/babel-core/test/errors-stacks.js index 2ad09059c607..4a38d98b6cd5 100644 --- a/packages/babel-core/test/errors-stacks.js +++ b/packages/babel-core/test/errors-stacks.js @@ -4,9 +4,19 @@ import { fileURLToPath } from "url"; import path from "path"; import { spawnSync } from "child_process"; import semver from "semver"; +import { readFileSync } from "fs"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); +let USE_ESM = false; +try { + const type = readFileSync( + new URL("../../../.module-type", import.meta.url), + "utf-8", + ).trim(); + USE_ESM = type === "module"; +} catch {} + const replaceAll = "".replaceAll ? Function.call.bind("".replaceAll) : (str, find, replace) => str.split(find).join(replace); @@ -288,7 +298,7 @@ describe("@babel/core errors", function () { `); }); - (semver.gte(process.version, "12.0.0") ? it : it.skip)( + (semver.gte(process.version, "12.0.0") && !USE_ESM ? it : it.skip)( "should not throw in `node --frozen-intrinsics`", function () { expect(