node-steamapi icon indicating copy to clipboard operation
node-steamapi copied to clipboard

Update imports in fetch.js to use Webpack 5 compatiable polyfills

Open mgscuteri opened this issue 3 years ago • 2 comments

Webpack 5 no longer automatically adds polyfills for the following imports in fetch.js

const { createDeflate, createGunzip } = require('zlib');
const { parse } = require('url');
const https = require('https');
const http = require('http');

This makes life very difficult for angular 13+

I think all that is needed is to run:

npm install browserify-zlib
npm install stream-http
npm install https-browserify
npm install url

and then update the imports in fetch.js to:

const { createDeflate, createGunzip } = require('browserify-zlib');
const { parse } = require('url');
const https = require('https-browserify');
const http = require('stream-http');

mgscuteri avatar Jun 04 '22 05:06 mgscuteri

The suggested solution does not work. Removing fetch entirely, and replacing it with axios does work.

mgscuteri avatar Jun 04 '22 07:06 mgscuteri

For anyone having issues with webpack 5, zlib, https, http, https-browserify or stream-http, see this fork may be helpful. https://github.com/mgscuteri/node-steamapi-webpack-5/blob/master/README.md

mgscuteri avatar Jun 04 '22 17:06 mgscuteri

I may update the package to use a build system. This wasn't really built with browser support in mind, though, since the Steam API has CORS. Can you tell me what your use case is exactly or if you're just using some proxy?

xDimGG avatar Jun 14 '23 21:06 xDimGG

Closing as stale. This may have already been resolved by the switch to node-fetch.

xDimGG avatar Sep 18 '23 01:09 xDimGG