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

Improve compatibility with browser by using better APIs #275

Closed
fregante opened this issue Jul 30, 2022 · 4 comments · Fixed by #280
Closed

Improve compatibility with browser by using better APIs #275

fregante opened this issue Jul 30, 2022 · 4 comments · Fixed by #280

Comments

@fregante
Copy link

fregante commented Jul 30, 2022

The browser compatibility claimed by this package is only due to bundlers’ polyfills, which are increasingly missing:

http and https can be replaced by fetch, which is available in Node 18 and can already be used everywhere with https://github.com/matthew-andrews/isomorphic-fetch. I think this would also avoid Buffer issues

URLs can be parsed with the URL constructor, available globally in Node 10.

They can all be replaced by their modern and cross-platform equivalents or they can use something like globalThis.process?.platform to ensure that they don't immediately fail when missing.

@philsturgeon
Copy link
Member

philsturgeon commented Jul 30, 2022

Thank you, this makes for a great Epic for folks to work from.

If anyone can take a swing at knocking out a few of these that sounds be hugely helpful.

@cihad
Copy link

cihad commented Sep 23, 2022

Maybe this will help: https://stackblitz.com/edit/webpack-webpack-js-org-vcdpkp?file=src/index.js

@alanpoulain
Copy link
Contributor

I've taken it, please wait for the PR when the Hacktoberfest starts 😄

@paztis
Copy link
Contributor

paztis commented Nov 15, 2023

it seems node-fetch dependency recreate this issue.
How to compile it now for browsers in webpack ?

node-fetch is importing node:http instead of http, node"fs instead of fs, ....
So all webapck classiuc NodePolyfills are no more working

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

Successfully merging a pull request may close this issue.

5 participants