wheresrhys / fetch-mock

Mock http requests made using fetch
http://www.wheresrhys.co.uk/fetch-mock/
MIT License
1.29k stars 182 forks source link

Latest version breaks builds #189

Closed Nickman87 closed 7 years ago

Nickman87 commented 7 years ago

Since the last update we are getting the following error during our test build:

WARNING in ./~/encoding/lib/iconv-loader.js
Critical dependencies:
9:12-34 the request of a dependency is an expression
 @ ./~/encoding/lib/iconv-loader.js 9:12-34
webpack: Compiled with warnings.

Rolling back to 5.10.0 solves the issue

branweb1 commented 7 years ago

Maybe mistaken but I think this is actually a node-fetch issue--or rather, an issue with a node-fetch dependency library called encoding (see discussion here: https://github.com/bitinn/node-fetch/issues/41).

One way to fix this (I think) is to install node-noop then do this in your wepback config:

new webpack.NormalModuleReplacementPlugin(/\/iconv-loader$/, 'node-noop')

If you're running your tests in a (headless) browser, you presumably don't need node-fetch at all. So theoretically you could just use the client version of fetch-mock and ditch node-fetch altogether. Haven't figured out how to do this yet unfortunately since compile-route.js uses node-fetch too.

Nickman87 commented 7 years ago

As that is the only change between 5.10.0 and 5.10.1 I'm guessing you're right. We run both in headless and normal mode so I'll try the suggestions given in the thread you linked. Thanks!