Node- and browser-specific implementations of blob helpers #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This uses the
imports
key inpackage.json
to point to different inner implementations ofcompressBlob
anddecompressBlob
in node vs. in other environments.The Node-specific implementation is based on the built-in
node:zlib
module and usesBuffer
s to convert between base64/utf8 strings and binary data. It has no dependencies, and node consumers can install the package with--no-optional
to avoid downloading them when installing this package.The browser implementation depends on
pako
andcore-js
. It uses polyfills ofUint8Array#toBase64()
and.fromBase64()
. for binary <-> base64 conversions, and relies on pako's behavior to handle utf8 encoding/decoding.This PR also restricts consumers to only importing stuff from the module entrypoint; reaching into subpaths manually is no longer allowed.
toolbox-devvit
(which should always be used in node contexts) without pulling in the optional dependencies - is specifying--no-optional
still necessary iftoolbox-devvit
's lockfile already reflects that the optional dependencies were skipped initially? maintaining this might be tricky