fix: polyfills for Node.js compatibility #170
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.
This pull request introduces significant updates to the
unenv-preset
package, focusing on enhancing Node.js polyfills and improving thehttps
request implementation. It also includes some minor code simplifications and reorganization. Below is a categorized summary of the most important changes:Enhancements to Node.js Polyfills:
internal/util
to mimic Node.js behavior, includinginherits
,MIMEType
,MIMEParams
,promisify
, and various type-checking utilities likeisRegExp
andisDate
. These updates improve compatibility with Node.js APIs. [1] [2] [3] [4] [5]util.js
file that consolidates exports frominternal/util
, providing a single entry point for utility functions and polyfills.Improvements to
https
Request Implementation:request
function inhttps.js
to support additional options (urlOrOptions
andoptionsOrCallback
) and handle headers, methods, and body formatting more robustly.setHeader
andremoveHeader
methods.options.timeout
parameter.Code Simplifications and Minor Changes:
polyfills/promises/index.js
by directly exportingpromisesContext
.util
andutil/types
in theunenv-preset
configuration.These changes collectively enhance the functionality and compatibility of the
unenv-preset
package, particularly for environments requiring Node.js polyfills.