Skip to content

Commit

Permalink
ESM: proper version check in hasStableEsmImplementation (#4653)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-fenster committed Jun 10, 2021
1 parent 8339c3d commit b20f3c9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/esm-utils.js
Expand Up @@ -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
Expand Down

0 comments on commit b20f3c9

Please sign in to comment.