Closed aviklai closed 4 years ago
Hi, @aviklai ! Good catch! Happy to work with you on this and share the fix with others :-)
Could you add node-fetch to Webpack's externals and see if that fixes the problem? This is what we did with geoblaze here: https://github.com/GeoTIFF/geoblaze/blob/master/webpack.base.js#L43
I'm not sure that will fix it though. Would you be able to share your webpack config and a little bit of the code that you are using to import the library? Are you using require
, import
or <script type="module" src="...">
? I think the problem might be that I haven't tested this library on mjs
builds! We happen to use umd
builds for GeoBlaze.
Thank you again and looking forward to fixing this.
Hi @DanielJDufour ,
I tried adding externals but it didn't fix the problem. I opened a pull request in which I have added a browser build as well. Now, when the library will be imported in a browser environment, it won't pull node-fetch because the build won't contain the node-fetch dependency. On the other hand, in node environment, it will be using node-fetch.
I merged your PR and republished. Please reopen if you are still having problem
Thank you!
Description: ReferenceError: global is not defined when importing the library on client-side.
To Reproduce When I try to import the library on a client-side project, I get the above error. It looks like the library is trying to import node-fetch on a client-side environment.
In index.js - the line:
import nodeFetch from 'node-fetch';
imports node-fetch in any environment.Expected behavior The library should work on the client-side as well.
Screenshots
Desktop:
Maybe it's possible to use isomorphic-fetch or cross-fetch?