Improve browserify/webpack support #333

Merged
merged 4 commits into from Aug 21, 2016

Projects

None yet

2 participants

@dduponchel
Collaborator
dduponchel commented Aug 10, 2016 edited

This pull request allows developers to remove the stream shim
from browserify/webpack bundles to reduce the final size. Moreover, we re-use
the existing stream shim to deduplicate code.

Edit: this is only true for recent browsers, see below.
Now, you can use --dg false --bare with browserify and

module.exports = {
  node: {
    "stream": "empty",
    global: false,
    process: false,
    Buffer: false
  }
};

as webpack configuration, JSZip won't throw an error.

Includes #329.

Edit:
JSZip depends on lie which needs the global variable. This is triggered in
old browsers and all versions of IE.
The minimalist browserify flags (to work in all browsers) are --no-builtins --insert-global-vars global and the minimalist webpack configuration is now

module.exports = {
  node: {
    "stream": "empty",
    global: true,
    process: false,
    Buffer: false
  }
};
Kirill89 and others added some commits Aug 5, 2016
@Kirill89 Kirill89 Fixed browserify support ccfd500
@dduponchel dduponchel Merge remote-tracking branch 'stuk/master' 7e115f0
@dduponchel dduponchel Improve browserify/webpack support.
With this commit, we now allow developers to remove the `stream` shim
from browserify/webpack bundles to reduce the final size. Moreover, we re-use
the existing `stream` shim to deduplicate code.

Now, you can use `--dg false --bare` with browserify and

```js
module.exports = {
  node: {
    "stream": "empty",
    global: false,
    process: false,
    Buffer: false
  }
};
```

as webpack configuration, JSZip won't throw an error.
6a4792f
@dduponchel dduponchel Browserify: add global in the build.
JSZip doesn't need it but `lie` (the `Promise` shim) does. This
dependency is only called when the js runtime doesn't provide a `Promise`.

The minimalist browserify flags (to work in all browsers) are `--no-builtins
--insert-global-vars global` and the minimalist webpack configuration is now

```js
module.exports = {
  node: {
    "stream": "empty",
    global: true,
    process: false,
    Buffer: false
  }
};
```

If the `global` object is not available in the bundle, you will get an
error in old browsers.
45d1700
@dduponchel dduponchel merged commit 04717d4 into Stuk:master Aug 21, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dduponchel dduponchel deleted the dduponchel:browserify branch Aug 21, 2016
@dduponchel dduponchel referenced this pull request Aug 22, 2016
Merged

Release v3.1.2 #340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment