danielwerg / r6api.js

🍫 Node.js wrapper around Rainbow Six Siege APIs
https://npm.im/r6api.js
MIT License
111 stars 19 forks source link

Issue when using Webpack #52

Closed Parzival42 closed 3 years ago

Parzival42 commented 3 years ago

Hi!

I am using r6api.js within an electron application (I am using the Vue CLI Plugin Electron Builder). However, it occurred to me that using r6api.js in combination with webpack fails due to:

TypeError: nodeFetch is not a function
    at eval (webpack:///./node_modules/r6api.js/lib/fetch.js?:10:3)

It seems like there is an issue using require together with webpack. For example quickly changing const nodeFetch = require('node-fetch'); to const nodeFetch = require('node-fetch').default; in /lib/fetch.js solves the issue for me. However, I didn't investigate too much if this may introduce other issues.

You can find some more infos about this problem here:

Is there any chance you could make r6api.js webpack ready? Thanks in advance!

danielwerg commented 3 years ago

Run into this issue myself the other day, using typescript branch myself which is works fine with webpack but obviously can't recommend you that because of breaking changes. Keep doing that you doing if it's works, will try to merge typescript branch after realese of North Star