Skip to content

Improve browserify/webpack support#333

Merged
dduponchel merged 4 commits intoStuk:masterfrom
dduponchel:browserify
Aug 21, 2016
Merged

Improve browserify/webpack support#333
dduponchel merged 4 commits intoStuk:masterfrom
dduponchel:browserify

Conversation

@dduponchel
Copy link
Copy Markdown
Contributor

@dduponchel dduponchel commented Aug 10, 2016

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 4 commits August 5, 2016 22:43
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.
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.
@EricSch
Copy link
Copy Markdown

EricSch commented Apr 24, 2017

Any configs or hints how it works for Rollup?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants