Comments (17)
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.
from encoding.
This module is meant for Node only, do not use it with webpack if it doesn't work
from encoding.
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.
from encoding.
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.
from encoding.
This works:
module: {
exprContextRegExp: /$^/,
exprContextCritical: false,
loaders: [/*...*/]
}
It invalidates all require(expr)
cases, i.e. this one, just as the Universe intended. Stolen from webpack/webpack#198 (comment).
from encoding.
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 require.extensions
to nullify those imports.
from encoding.
Eventually I realized that doing that is an overkill and I can just use require.extensions to nullify those imports.
How?
from encoding.
Use the 'whatwg-fetch' instead of 'node-fetch'
from encoding.
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.
from encoding.
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.
from encoding.
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 /\/iconv-loader$/
from encoding.
Updated code to load Iconv as you suggested. Released as v0.1.12
from encoding.
Thank you!
from encoding.
Won't this cause an error as soon as it's run with Node? I'm getting this:
Error: Cannot find module "./iconv-loader"
I think it's meant only for require
s inside a try...catch
block?
from encoding.
@jimpick that's much cleaner, thanks 👍
from encoding.
@rublev sorry for a much too late reply, but if you're using Jest, you can configure moduleNameMapper
. Otherwise you can use ignore-styles or something like that.
from encoding.
new webpack.NormalModuleReplacementPlugin(//iconv-loader$/, 'node-noop')
Is the double slash //
before iconv-loader intended?
from encoding.
Related Issues (13)
- Detecting charset HOT 1
- fails with iconv-lite unsupported encoding error HOT 3
- Null bytes not trimmed. HOT 3
- test failure for ISO-2022-JP HOT 1
- iconv-loader webpack issue HOT 19
- about auto detect charset HOT 1
- Buffer() is deprecated HOT 1
- Critical dependency: the request of a dependency is an expression HOT 1
- Error: Cannot find module 'iconv
- Just use iconv-lite? HOT 7
- Please add copyright statement and license text HOT 4
- iconv-lite version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from encoding.