Skip to content
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

Allow customization of fetch #383

Open
salmenf opened this issue Sep 26, 2024 · 2 comments
Open

Allow customization of fetch #383

salmenf opened this issue Sep 26, 2024 · 2 comments

Comments

@salmenf
Copy link

salmenf commented Sep 26, 2024

For my use case, I am trying to set up resolving certain installs of packages through the FileSystem API. With a custom provider, generating the right URLs is straighforward, but I run into Module not found errors once I try to run install, of course (since the files are not accessible via any URL).

It would be great if I could overwrite fetch to give custom responses. This could be global (extending fetchOptions) or tied to the provider. Then, I could for example respond to fetch("my/local/url") by accessing the File System through the FileSystem API, creating a Response object and returning it.

I appreciate the previous changes, by the way, my use case is really coming together thanks to your work! :)

@guybedford
Copy link
Member

This is a good suggestion, I've put something together in #385, let me know if that can work for you.

@salmenf
Copy link
Author

salmenf commented Sep 30, 2024

That's great, thank you! Should work perfectly for me: I can setFetch with my own implementation where I match the given URL and perform my file system access, or fall back to the default fetch implementation for all other URLs.

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

No branches or pull requests

2 participants