Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upzlib: add Brotli support #24938
Conversation
addaleax
added
zlib
semver-minor
notable-change
brotli
labels
Dec 10, 2018
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot
added
the
meta
label
Dec 10, 2018
This comment has been minimized.
This comment has been minimized.
addaleax
referenced this pull request
Dec 10, 2018
Closed
zlib: split JS code as prep for non-zlib-backed streams #24939
mscdex
requested changes
Dec 10, 2018
|
I would much rather this live in a separate module or perhaps in a new namespace (which would still require a new 'module' anyway -- but would be better for organizational purposes) that can house all compression methods. I don't think stuffing this into |
This comment has been minimized.
This comment has been minimized.
As I said in the PR description, that’s not the only reason for this.
It does matter that said fact makes the APIs analogous, imo. It also means that a bug or feature request for one part of the API likely applies to the other part of the API as well. |
addaleax
force-pushed the
addaleax:brotli
branch
from
ae7dc7f
to
32e8931
Dec 10, 2018
This comment has been minimized.
This comment has been minimized.
|
For those reviewing you can look at the below subset to avoid seeing the addition of the brotli dep itself |
This comment has been minimized.
This comment has been minimized.
kristoferbaxter
commented
Dec 10, 2018
|
Interesting approach, and the API looks quite simple and usable to me. This would be a great way to address the issue. |
This comment has been minimized.
This comment has been minimized.
That's an internal concern though, not something the end user should care about. Anyway, I still believe we should be doing this more correct from the get-go by incorporating and using a new namespace instead. |
This comment has been minimized.
This comment has been minimized.
|
@mscdex if we move to a new namespace are we imagining |
This comment has been minimized.
This comment has been minimized.
|
I'm+1 on the approach suggested by @addaleax. I have to review the code more to sign off tho |
This comment has been minimized.
This comment has been minimized.
I recognize |
This comment has been minimized.
This comment has been minimized.
|
Would it make sense to avoid overlapping with existing npm packages by using special characters? require('#brotli');or use a different method maybe: require.internal('brotli');
require.stdlib('brotli'); |
This comment has been minimized.
This comment has been minimized.
|
@MayhemYDG please take a look at #21551 where we are exploring introducing a Node.js namespace in which we can put future modules. This would solve the problem in a slightly more elegant way imho @mscdex would you be open to landing this within the I'd like to propose we do the following
|
This comment has been minimized.
This comment has been minimized.
That sounds like replicating the original mistake here – we shouldn’t be naming anything |
This comment has been minimized.
This comment has been minimized.
|
@addaleax I've updated the above plan to rename zlib and add a deprecation warning to the compat alias. |
This comment has been minimized.
This comment has been minimized.
No, as that is something that would probably happen eventually anyway if namespaces do get added. |
This comment has been minimized.
This comment has been minimized.
|
One approach moving forward could be:
|
This comment has been minimized.
This comment has been minimized.
|
@mscdex Instead of just saying that the reasons I provided for putting this feature in |
This comment has been minimized.
This comment has been minimized.
I hinted at this initially, but I believe it's confusing/misleading and not the correct place for this new API from an organizational standpoint since brotli is not zlib-compatible nor is it a format supported by the standard zlib library. Is that what you were asking for? |
This comment has been minimized.
This comment has been minimized.
|
@mscdex Okay – I’m not convinced by this, tbh… none of the other formats under Again, I understand that it’s unfortunate that the module was named |
This comment has been minimized.
This comment has been minimized.
The formats supported by node are all supported by the actual underlying zlib library, so it makes sense that they're available under the
I also prefer that they all live under one module/namespace. I just believe that |
This comment has been minimized.
This comment has been minimized.
|
/cc @nodejs/collaborators for opinions on the naming & reviews |
This comment has been minimized.
This comment has been minimized.
|
I don't think most people who use the Renaming it longer term to |
This comment has been minimized.
This comment has been minimized.
|
CI is green, I believe this is ready to land |
addaleax
removed
the
tsc-agenda
label
Jan 5, 2019
This comment has been minimized.
This comment has been minimized.
|
Landed in 345d3f3...b91093f |
addaleax commentedDec 10, 2018
•
edited
Add Brotli support to the zlib module; in particular:
zlib.createBrotliCompress(),zlib.brotliCompress(),zlib.brotliCompressSync()zlib.createBrotliDecompress(),zlib.brotliDecompress(),zlib.brotliDecompressSync()The APIs are identical to the zlib ones, except for the way that some of the more algorithm-specific options are passed to the stream constructor and a missing
.params()function (because Brotli does not support that).This PR is based on @Hackzzila’s #20458, although the internals are quite different, and re-uses more of the existing zlib infrastructure.
Some more visible differences to the main PR are:
zlibmodule, rather than introducing a new module. I expect this to be somewhat controversial, given that this makes the naming of the module seem somewhat unfortunate.zlib, and that name has been unforunate since the module was first created, but ultimately, our users don’t care which library the streams are actually backed by, and so we shouldn’t either.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes