-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix browser module resolution #614
Conversation
When webpack/rollup or another bundler, implementing the [`browser-resolve`](https://www.npmjs.com/package/browser-resolve) spec tries to resolve `jszip` for a browser-based project they fail with: ``` ERROR in ./node_modules/jszip/lib/readable-stream-browser.js Module not found: Error: Can't resolve 'stream' in '/node_modules/jszip/lib' ``` Since you already produce a browser build, we just need to point to it inside of `package.json`'s `browser` field. PS: You'd probably want to double check the semantics of `"."`. Looking at `browser-resolve` it seems that everything will work as expected. Also, trying empirically with webpack, everything worked out, but few more pairs of eyes would be greatly appreciated. Also @sokra should be able to share a valuable opinion. Fix Stuk#524 Fix Stuk#521 Fix Stuk#477
@Stuk the build seems to be timing out. Doesn't look related to the change. |
@Stuk can you merge this, so we could build Angular 8 apps using jszip? |
Thanks for the PR! I just tried bundling JSZip with webpack and parcel and had no issues. This is my testing {
"name": "jszip-package-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"jszip": "^3.2.2",
"parcel-bundler": "^1.12.3",
"webpack": "^4.39.3",
"webpack-cli": "^3.3.8"
}
} Both Could you create a package.json, or repository that reproduces the issue? |
Here it is. Run:
|
Thanks! I can repro. I need to understand the impact of this PR on Webpack/Browserify/Parcel etc. bundles. I think it might increase bundle sizes for folks, because there could be 2 stream implementations in the bundle: 1 in the JSZip dist, and another one added by the bundler. If you're able to help me understand the impact, I'd very much appreciate it. |
I'm using Angular 8 and the latest version of jszip and I'm seeing the same error when I build my project:
If the error cames from the file deadable-stream-browser.js
|
Hi @Stuk is there any news on this? is it possible to merge this PR? |
Just spent some time checking that this doesn't adversely affect webpack or parcel, and it looks like it's ok. Tested here |
Published as v3.3.0 |
When webpack/rollup or another bundler, implementing the
browser-resolve
spec tries to resolve
jszip
for a browser-based project they failwith:
Since you already produce a browser build, we just need to point to
it inside of
package.json
'sbrowser
field.PS: You'd probably want to double check the semantics of
"."
.Looking at
browser-resolve
it seems that everything will workas expected. Also, trying empirically with webpack, everything worked
out, but few more pairs of eyes would be greatly appreciated.
Also @sokra should be able to share a valuable opinion.
Fix #524
Fix #521
Fix #477