using webpack problem
Closed this issue · 5 comments
hi, js-md5 will use Node.js method in Node.js environment. see
https://github.com/emn178/js-md5/blob/master/src/md5.js#L126-L127
If webpack finds that source code includes require('xxx')
, it will include the dependencies in bundle file.
Sorry, but I can't stop webpack doing this.
If you don't want to include anyway, you can remove the part related to Node.js from source code.
I found a way to ignore the dependencies. Set up your webpack config by this.
var webpack = require('webpack');
module.exports = {
// ...
plugins: [
new webpack.IgnorePlugin(/^crypto$/),
new webpack.IgnorePlugin(/^buffer$/)
]
};
Remember to remove if other libraries really need these.
thanks @emn178 , webpack plugins could solve the problem. I guess it's pretty simple to do md5 within nodejs, what do you think make js-md5 a pure front-end lib, :)
I make it provides the same interface so that you can write an application run in both front-end and back-end with this library.
Different syntax for ignorePlugin
in webpack 5?