-
Notifications
You must be signed in to change notification settings - Fork 44
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
Warnings with webpack. #16
Comments
This module is meant for Node only, do not use it with webpack if it doesn't work |
I use this module in node env. With webpack, the server side application can be packaged in one js file with only required source files included. |
This behavior with require as an expression is intentional to be able to load iconv in environments where it is supported and fall back to iconv-lite where it is not. Webpack support is not a priority. |
Currently, webpack is ok except the above warning. But change these 2 lines var iconv_package = 'iconv';
Iconv = require(iconv_package).Iconv; to Iconv = require('iconv').Iconv; will allow user to avoid the warning. |
This change would break browserify which is more used than webpack. I'm willing to change the code to support webpack as well but only if it doesn't break anything existing. |
OK, thank you. There is a way to do that: Iconv = require('./iconv-loader'); and // file: iconv-loader.js
var pkg = 'iconv';
module.exports = require(pkg); and then, user can use webpack.IgnorePlugin to ignore |
Updated code to load Iconv as you suggested. Released as v0.1.12 |
Thank you! |
Won't this cause an error as soon as it's run with Node? I'm getting this:
I think it's meant only for |
This works: module: {
exprContextRegExp: /$^/,
exprContextCritical: false,
loaders: [/*...*/]
} It invalidates all |
IgnorePlugin didn't work for me, when I used it, webpack put in some code that throws an error. I did this instead in plugins: new webpack.NormalModuleReplacementPlugin(//iconv-loader$/, 'node-noop') I needed to install the node-noop npm module. |
@jimpick that's much cleaner, thanks 👍 |
Use the 'whatwg-fetch' instead of 'node-fetch' |
whatwg-fetch does not work in Node, which is why isomorphic-fetch exists. This issue is probably most common when you're trying to compile your tests with webpack before running them, so you have good control over how some special stuff like CSS imports will be handled. Eventually I realized that doing that is an overkill and I can just use |
How? |
@rublev sorry for a much too late reply, but if you're using Jest, you can configure |
Is the double slash |
Related code: https://github.com/andris9/encoding/blob/master/lib/encoding.js#L9
Please dont try to fool webpack, users can use webpack.IgnorePlugin to prevent loading of 'iconv'.
The text was updated successfully, but these errors were encountered: