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

Conversation

Projects
None yet
3 participants
@dduponchel
Collaborator

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 some commits Aug 5, 2016

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.
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.

@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

@EricSch

This comment has been minimized.

Show comment
Hide comment
@EricSch

EricSch Apr 24, 2017

Any configs or hints how it works for Rollup?

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