-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Circumvent issues with ESM process polyfills
- Loading branch information
1 parent
a2e9aed
commit f1c640c
Showing
8 changed files
with
34 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* wraps the internal process module, circumventing issues with some polyfills (see #539) */ | ||
|
||
/** @type {import('node:process')} */ | ||
const process = ((base, esmKey, keys, isValid) => { | ||
// check if top-level es module, in which case it may have a default export | ||
if (esmKey in base && base[esmKey] === true) { | ||
let candidate | ||
for (const key of keys) { | ||
if (!(key in base)) { | ||
continue | ||
} | ||
candidate = base[key] | ||
// sanity check | ||
if (isValid(candidate)) { | ||
return candidate | ||
} | ||
} | ||
} | ||
return base | ||
})( | ||
require('process/'), | ||
'__esModule', | ||
['default', 'process'], | ||
(candidate) => 'nextTick' in candidate | ||
) | ||
|
||
module.exports = process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters