-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
browserify build #74
browserify build #74
Conversation
Looks good. I need to play around with it locally. |
a couple notes:
|
I started playing with this pull request and here are some thoughts :
|
|
zlib.js has a bin/ folder containing the generated files. I tested with
and in Regarding the
This could also generate merge conflicts in the minified file. We could create an other branch to contains the Thoughts ? |
first on the dist front the usual route in my experience is some combination of 1 and 2. The key is to make it clear that people who pull are not to commit them and then it ends up not being much of a deal. for zlib it occurs to me we could just use the zlib which browserify adds if you do |
compressInputType: null, | ||
uncompressInputType: null | ||
}; | ||
exports.DEFLATE = require('./flate'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requiring directories with an index.js
file is not supported by other CommonJS module loaders like Mr. This should be changed to ./flate/index
or rename "lib/flate/index.js" to "lib/flate.js".
One thing I was considering is allowing the // everything
var JSZip = require("jszip");
// optionally loading
var JSZip = require("jszip/base")
JSZip.addCompression(require("jszip/deflate"));
JSZip.addCompression(require("jszip/inflate"));
JSZip.prototype.load = require("jszip/load"); Any thoughts? These are the filesizes: # before
173K Oct 20 11:19 jszip.js
69K Oct 20 11:19 jszip.min.js
# after
149K Oct 20 11:57 jszip.js
60K Oct 20 11:57 jszip.min.js |
Amusingly It appears that browserify is shimming Buffer: https://github.com/calvinmetcalf/jszip/blob/7e47cfd75d4cbdcdab6721c80a9a80ed22280c39/dist/jszip.js#L3189. Any ideas if this can be disabled? |
this has come up in daleharvey/pouchdb#921, we'd have to make sure Buffer was only ever called from some node only files and then exclude that from the build OR as the buffer shim doesn't use typed arrays, use the NodeReader as a fallback for things that don't have arrays buffers. as for size things, gzipped in this current config you save 4k by excluding deflate and inflate (so 2k each) and you save 1.6k by excluding load. it would make more sense if there were multiple algorithms that might be used, but at the moment it comes down to saving ~2k if your only going one way (deflate or inflate) and then saving ~1.6k if your not actual loading somebody else's zipfile? not sure what the load part actually does. In my experience custom builds don't get used much and end up not being used a ton, it seems like not much of a gain for a lot of extra hasle for people. |
I'm still don't think that commiting generated files is a good idea but this seems to be the easiest path. As you pointed out @calvinmetcalf, this is done by a lot of js devs (for each commit or for each release). Other repositories use a custom tarball with npm (I've never published any package on npm but that seems possible) or have a separated repository (angularjs but that's the only one I found). With other package managers (see #19) adding generated files may be the easiest solution. The zlib wrapper won't work for us : the nodejs API is asynchronous while JSZip has a synchronous API (but that would have been nice). The Buffer shim adds a lot of code :
I think we should set |
your right about zlib my bad. I'm somewhat hesitant about relying on the external zlib.js as it brings in some other stuff but it's still better then bringing it with. I believe we can do better then |
ok used @dduponchel's method for moving zlib out of here, also moved new Buffer and Buffer.isBuffer into a new module that we can then ignore in the build process (along with nodeBufferReader) before Original: 159374 bytes.
Minified: 71022 bytes.
Gzipped: 16075 bytes. now Original: 93148 bytes.
Minified: 44675 bytes.
Gzipped: 10773 bytes. |
Nice ! |
var Zlib = require('zlibjs/bin/rawinflate.min').Zlib | ||
module.exports = function(Type){ | ||
return function(input) { | ||
var inflate = new Zlib.RawInflate(new Type(input)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That won't work with arrays (will create an array containing an array).
The conversion is already handled by the calling function, following the uncompressInputType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it looks like the use typed array thing is actually something from zlib.js that we don't need now that it's in a separate file
Sorry for the lack of update ! |
Merged into master. |
first stab at it pretty much an updated version of the one currently up there, need to get the tests passing in node (browser works) which may be a challenge for me as I don't really know quint well (as opposed to mocha).