From b20f3c953d21540ed6846feb060638f36cb48cac Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Wed, 9 Jun 2021 23:40:26 -0700 Subject: [PATCH] ESM: proper version check in hasStableEsmImplementation (#4653) --- 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