Skip to content

Commit

Permalink
Fix browser module resolution
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgechev committed Aug 21, 2019
1 parent 8742db3 commit 617e3ce
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 617e3ce

Please sign in to comment.