JSZip not working with Webpack
I get this error while using Webpack
WARNING in ./bower_components/jszip/dist/jszip.js
Critical dependencies:
12:436-443 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./bower_components/jszip/dist/jszip.js 12:436-443
Also, requests the following modules: base64-js, ieee754, is-array
Does anybody have a solution? Thank you!
How are you loading it? Importing it?
I get the same warning with a bower installation (but I get a fully functional JSZip object).
When using bower to install JSZip, you won't get the dependencies and will need to use the dist/ file (hence the warning).
If you use npm, a require("jszip") will work too, without warning.
I loaded lib/index.js with the imports loader (bower install)
Imports?JSZIP!jszip
Where jszip is a resolve.alias to the index.js
B mobile phone
On Feb 2, 2016, at 12:26 PM, David Duponchel [email protected] wrote:
I get the same warning with a bower installation (but I get a fully functional JSZip object). When using bower to install JSZip, you won't get the dependencies and will need to use the dist/ file (hence the warning). If you use npm, a require("jszip") will work too, without warning.
— Reply to this email directly or view it on GitHub.
I loaded it through webpack.config.js, using alias
resolve: {
modulesDirectories: ['.', 'bower_components'],
alias: {
jszip: 'jszip/dist/jszip.js'
}
}
and I've got the error mentioned above
WARNING in ./bower_components/jszip/dist/jszip.js
Critical dependencies:
12:436-443 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ./bower_components/jszip/dist/jszip.js 12:436-443
@okbel I have
{
resolve: {
alias: {
jszip: path.join(__dirname, 'bower_components/jszip/lib/index.js') // src
}
},
loaders: [
{ test: /bower_components\/jszip\/.*\.js$/, loader: 'imports?JSZIP=jszip' }
]
}
possibly try adding this=>window,define=>false... I'm using it a bit differently
any possible work arounds to make it work with webpack?
@suryaiiit works for me with webpack as I've commented above. no workarounds, just using what webpack gives you
@jamesbillinger posted a solution to this over at https://github.com/SheetJS/js-xlsx/issues/397
In short, you just need to let webpack know that jszip is a pre-bundled module by adding
externals: [ {'./jszip': 'jszip'}]
in your webpack config.
Thanks @jamesbillinger! 👍
Just thanks for all the sharing. What happened to me is, after I changed