feat: add install() function for global WHATWG fetch classes#4286
Merged
feat: add install() function for global WHATWG fetch classes#4286
Conversation
Add a top-level install() export that installs all WHATWG fetch classes on globalThis, making them available globally without imports. - Add install() function to index.js that sets globalThis properties - Include fetch, Headers, Response, Request, FormData, WebSocket, events, and EventSource - Add comprehensive test coverage for the install function - Document the feature in README.md with usage examples - Add API documentation for the docs website This is useful for polyfilling environments, ensuring consistent fetch behavior across Node.js versions, and making undici's implementations available globally for libraries that expect them. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matteo Collina <hello@matteocollina.com>
Refactor the install() function to be declared as a top-level function instead of an anonymous function assigned to module.exports.install. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matteo Collina <hello@matteocollina.com>
KhafraDev
approved these changes
Jun 19, 2025
Ethan-Arrowood
approved these changes
Jun 19, 2025
anonrig
approved these changes
Jun 20, 2025
Member
|
Thanks! |
metcoder95
approved these changes
Jun 20, 2025
Merged
1 task
slagiewka
pushed a commit
to slagiewka/undici
that referenced
this pull request
Feb 14, 2026
…4286) * feat: add install() function for global WHATWG fetch classes Add a top-level install() export that installs all WHATWG fetch classes on globalThis, making them available globally without imports. - Add install() function to index.js that sets globalThis properties - Include fetch, Headers, Response, Request, FormData, WebSocket, events, and EventSource - Add comprehensive test coverage for the install function - Document the feature in README.md with usage examples - Add API documentation for the docs website This is useful for polyfilling environments, ensuring consistent fetch behavior across Node.js versions, and making undici's implementations available globally for libraries that expect them. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matteo Collina <hello@matteocollina.com> * refactor: make install function a top-level function Refactor the install() function to be declared as a top-level function instead of an anonymous function assigned to module.exports.install. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matteo Collina <hello@matteocollina.com> --------- Signed-off-by: Matteo Collina <hello@matteocollina.com> Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
install()export that installs all WHATWG fetch classes onglobalThisChanges
install()function inindex.jsthat sets globalThis propertiestest/install.jswith comprehensive test coverageUse Cases
This is useful for:
Test Plan
test/install.jsverifies function installs all classes correctlyFixes #4285
🤖 Generated with Claude Code