Skip to content

fix: streamline stream polyfills and enhance process, module, setInterval #169

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 2, 2025

Conversation

jcbsfilho
Copy link
Collaborator

This pull request introduces several updates to polyfills and module handling across the codebase, focusing on improving compatibility, restructuring exports, and enhancing functionality. Key changes include refactoring the stream polyfills, adding new polyfills for setInterval and process.uptime, and restructuring the Module polyfill for better alignment with Node.js behavior.

Stream Polyfills Refactoring:

  • Refactored stream.context.js to use a localStream object for managing stream types and their exports, simplifying the structure and improving encapsulation. ([packages/bundler/src/polyfills/stream/context/stream.context.jsL4-R16](https://github.com/aziontech/lib/pull/169/files#diff-8009e89b001c18478e6d44348627034134f8e65f8cdbff1a37a74d8c2168141dL4-R16))
  • Updated stream.polyfills.js to enhance the Readable.toWeb method with proper cleanup of event listeners and added a Writable.fromWeb method for compatibility with web streams. ([[1]](https://github.com/aziontech/lib/pull/169/files#diff-0b1a2b0e278265f900e651f94218447cc5b3532f647b7250e840bfe7c3d0ed41L2-R57), [[2]](https://github.com/aziontech/lib/pull/169/files#diff-0b1a2b0e278265f900e651f94218447cc5b3532f647b7250e840bfe7c3d0ed41L48-R85), [[3]](https://github.com/aziontech/lib/pull/169/files#diff-0b1a2b0e278265f900e651f94218447cc5b3532f647b7250e840bfe7c3d0ed41L95-R129))

New Polyfills:

  • Introduced a polyfill for setInterval to ensure compatibility with libraries like Sentry by adding unref and ref methods to the returned object. ([packages/unenv-preset/src/polyfills/node/globals/set-interval.jsR1-R21](https://github.com/aziontech/lib/pull/169/files#diff-759dc6139dfdef6533e9e074cc8f702a9b82ffffc765cbc827cbebae301ddc6eR1-R21))
  • Added process.uptime to the process polyfill, calculating uptime based on a global startTime. ([[1]](https://github.com/aziontech/lib/pull/169/files#diff-4f9211a326dd4f40bdb7d63f99be7fc9873aa2446e6423e8bf9ab8eb9e59904aR3-R4), [[2]](https://github.com/aziontech/lib/pull/169/files#diff-4f9211a326dd4f40bdb7d63f99be7fc9873aa2446e6423e8bf9ab8eb9e59904aR194-R197))

Module Polyfill Restructuring:

  • Reorganized the Module polyfill, replacing the previous export object with a more structured Module object that includes static properties and methods, aligning it more closely with Node.js's module system. ([[1]](https://github.com/aziontech/lib/pull/169/files#diff-3d740d5b47fd36e31cfb4156fc9d134df6fee7e1f61d77c347be87435ba73ebeL11-R11), [[2]](https://github.com/aziontech/lib/pull/169/files#diff-3d740d5b47fd36e31cfb4156fc9d134df6fee7e1f61d77c347be87435ba73ebeL87-R155))

Other Updates:

  • Updated the performance polyfill path in the unenv-preset package to use a new location (unenv/polyfill/performance). ([packages/unenv-preset/src/index.tsL15-R16](https://github.com/aziontech/lib/pull/169/files#diff-40a0c89863390a48518ad7870d9042ad049b987f88f48b67368e0b4f9570a450L15-R16))

@jcbsfilho jcbsfilho merged commit 118f7bb into stage Jun 2, 2025
2 checks passed
@jcbsfilho jcbsfilho deleted the fix/polyfills branch June 2, 2025 18:37
jotanarciso pushed a commit that referenced this pull request Jun 2, 2025
[skip ci]
## [1.20.0-stage.7](v1.20.0-stage.6...v1.20.0-stage.7) (2025-06-02)

### Bug Fixes

* streamline stream polyfills and enhance process, module, setInterval (#169) ([118f7bb](118f7bb))
@jotanarciso
Copy link
Collaborator

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

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