refactor!: rewrite process
as class
#450
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have implemented
node:process
with named exports to mimicglobal.process
and allow hybrid implementation interface however real process in Node.js extends EventEmitter (process instanceof events.EventEmitter === true
) and we cannot have features such as lazy getters or warning on access with just named exports. current process polyfill is also kinda messy!with This PR:
EventEmitter
stdin
/stdout
/stderr
are lazily initialized for perf on first access (named exports fromnode:process
deoptimizes!)_*
internals marked asundefined
to avoid implicit behavior and also reduce bundleUnenvProcess
class acceptingenv
,hrtime
andnextTick
implementation from constructor.unenv/polyfill/process
extendsglobalThis.process
(if exists) with aProxy
that only fallbacks to unenv one if does not has same prop (relevant to Nitro)hybrid presets
With this new implementation, hybrid presets such as clouflare can directly pass internal implementation to factory class: