-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Critical dependencies: request of a dependency is an expression in encoding.js #41
Comments
Depends on how you are building your app, this can be an issue with your build tool or build config. You might want to raise this issue to the developer of your build tool (as I can't debug that error message). PS: node-fetch is a server-side implementation, so your client-side build should contain the whatwg-fetch (fetch polyfill, as specified in isomorphic-fetch), See #24 on this topic. |
I am using webpack to build. Here's my server config
I am new to node and webpack, but I think the problem is in the encoding module, specifically this line https://github.com/andris9/encoding/blob/master/lib/encoding.js#L9. If my understanding of the situation is correct, when I specify target: node in the server config, it tells isomorphic-fetch to use node-fetch which uses encoding which dynamically loads iconv and when webpack encounters a dynamic require it complains that the request of a dependency is an expression The funny thing is that everything works :) But I would still like to get to the bottom of this ... |
You need to take this issue to webpack and encoding modules. I believe encoding module is not at fault (as in node.js allows it). It's more likely webpack had issue dealing with this module and need some extra config or workaround. You shouldn't be building server-side script anyway, you may transpile es6 to node.js, but building a bundle or minification ain't necessary for node. |
An example where it makes sense to build server-side scripts is when you're using webpack and have weird stuff like isomorphic-fetch is handy in this case because we use whatwg-fetch on client-side and node-fetch for testing. |
Related: andris9/encoding#16. Apparently you can just add: new webpack.IgnorePlugin(/\/iconv-loader$/) to webpack plugins and it should work. However, for me it throws |
@silvenon either |
@bitinn sorry, by "you" I meant the user, not you 😉 I figured out why I had an error and posted a better solution on the issue I referenced. I added it to the docs of Have a good day ⛄ |
Use the 'whatwg-fetch' instead of 'node-fetch' |
you'll hit this a lot when using I can only speak to its implementation in my project framework ( |
Hello
I get an error when I try to build universal react app with redux and icomorphic-fetch.
It's this piece of code in encoding.js that is causing the problems
Any ideas on how to fix this?
The text was updated successfully, but these errors were encountered: