From b0e6bd61629b9d4c203fe8a678c60e3b5724963a Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Mon, 7 Jun 2021 12:09:11 -0700 Subject: [PATCH] fix: proper version check in hasStableEsmImplementation --- lib/esm-utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/esm-utils.js b/lib/esm-utils.js index 14a9c28fa8..d4acf06cb6 100644 --- a/lib/esm-utils.js +++ b/lib/esm-utils.js @@ -34,7 +34,9 @@ const hasStableEsmImplementation = (() => { const [major, minor] = process.version.split('.'); // ESM is stable from v12.22.0 onward // https://nodejs.org/api/esm.html#esm_modules_ecmascript_modules - return parseInt(major.slice(1), 10) > 12 || parseInt(minor, 10) >= 22; + const majorNumber = parseInt(major.slice(1), 10); + const minorNumber = parseInt(minor, 10); + return majorNumber > 12 || (majorNumber === 12 && minorNumber >= 22); })(); exports.requireOrImport = hasStableEsmImplementation