fix: streamline stream polyfills and enhance process, module, setInterval #169
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 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 forsetInterval
andprocess.uptime
, and restructuring theModule
polyfill for better alignment with Node.js behavior.Stream Polyfills Refactoring:
stream.context.js
to use alocalStream
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)
)stream.polyfills.js
to enhance theReadable.toWeb
method with proper cleanup of event listeners and added aWritable.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:
setInterval
to ensure compatibility with libraries like Sentry by addingunref
andref
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)
)process.uptime
to theprocess
polyfill, calculating uptime based on a globalstartTime
. ([[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:
Module
polyfill, replacing the previous export object with a more structuredModule
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:
performance
polyfill path in theunenv-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)
)