From 617e3ce439c1a0c694c2cb0a04f4a7578d94291f Mon Sep 17 00:00:00 2001 From: mgechev Date: Tue, 20 Aug 2019 17:45:58 -0700 Subject: [PATCH] Fix browser module resolution 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 #524 Fix #521 Fix #477 --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index de104997..728ea1b0 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ ], "main": "./lib/index", "browser": { - "readable-stream": "./lib/readable-stream-browser.js" + "readable-stream": "./lib/readable-stream-browser.js", + ".": "./dist/jszip.min.js" }, "repository": { "type": "git",