Skip to content
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

Improve browserify/webpack support #333

Merged
merged 4 commits into from
Aug 21, 2016
Merged

Conversation

dduponchel
Copy link
Collaborator

@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

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.

None yet

3 participants