Skip to content

fix: polyfills for Node.js compatibility #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2025
Merged

Conversation

jcbsfilho
Copy link
Collaborator

This pull request introduces significant updates to the unenv-preset package, focusing on enhancing Node.js polyfills and improving the https 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:

  • Added a comprehensive set of utility functions and classes in internal/util to mimic Node.js behavior, including inherits, MIMEType, MIMEParams, promisify, and various type-checking utilities like isRegExp and isDate. These updates improve compatibility with Node.js APIs. [1] [2] [3] [4] [5]
  • Introduced a new util.js file that consolidates exports from internal/util, providing a single entry point for utility functions and polyfills.

Improvements to https Request Implementation:

  • Refactored the request function in https.js to support additional options (urlOrOptions and optionsOrCallback) and handle headers, methods, and body formatting more robustly.
  • Added support for setting and removing headers dynamically via setHeader and removeHeader methods.
  • Enhanced response handling by implementing an async iterator for streaming response data and improving chunk processing.
  • Made the timeout duration configurable via the options.timeout parameter.

Code Simplifications and Minor Changes:

  • Simplified the default export in polyfills/promises/index.js by directly exporting promisesContext.
  • Added new polyfill paths for util and util/types in the unenv-preset configuration.

These changes collectively enhance the functionality and compatibility of the unenv-preset package, particularly for environments requiring Node.js polyfills.

@jcbsfilho jcbsfilho merged commit 329f4c4 into stage Jun 6, 2025
2 checks passed
@jcbsfilho jcbsfilho deleted the fix/support-opennextjs branch June 6, 2025 18:04
jotanarciso pushed a commit that referenced this pull request Jun 6, 2025
[skip ci]
## [1.20.0-stage.9](v1.20.0-stage.8...v1.20.0-stage.9) (2025-06-06)

### Bug Fixes

* polyfills for Node.js compatibility (#170) ([329f4c4](329f4c4))
@jotanarciso
Copy link
Collaborator

🎉 This PR is included in version 1.20.0-stage.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants