From eca4f6bce67549570a009f0fea1eb037a5cdd248 Mon Sep 17 00:00:00 2001 From: JasonFyfe <73648977+JasonFyfe@users.noreply.github.com> Date: Tue, 22 Oct 2024 05:52:17 +0100 Subject: [PATCH] fix(jest): Handle process.version undefined (#64) In the event that `process.version` is undefined then return "es2018" as expected. --- .changeset/good-lobsters-search.md | 5 +++++ packages/jest/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/good-lobsters-search.md diff --git a/.changeset/good-lobsters-search.md b/.changeset/good-lobsters-search.md new file mode 100644 index 0000000..8d8bcc3 --- /dev/null +++ b/.changeset/good-lobsters-search.md @@ -0,0 +1,5 @@ +--- +"@swc/jest": patch +--- + +Return es2018 in the event that process.version is undefined. diff --git a/packages/jest/index.ts b/packages/jest/index.ts index d9bf340..21684c2 100644 --- a/packages/jest/index.ts +++ b/packages/jest/index.ts @@ -144,7 +144,7 @@ function buildSwcTransformOpts( computedSwcOptions, "jsc.target", // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - nodeTargetDefaults.get(process.version.match(/v(\d+)/)![1]) || + nodeTargetDefaults.get(process.version?.match(/v(\d+)/)![1]) || "es2018" ); }