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

Node- and browser-specific implementations of blob helpers #69

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

eritbh
Copy link
Member

@eritbh eritbh commented Feb 28, 2025

This uses the imports key in package.json to point to different inner implementations of compressBlob and decompressBlob in node vs. in other environments.

The Node-specific implementation is based on the built-in node:zlib module and uses Buffers 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 and core-js. It uses polyfills of Uint8Array#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.

  • README docs about the optional dependencies
    • figure out the story for installing toolbox-devvit (which should always be used in node contexts) without pulling in the optional dependencies - is specifying --no-optional still necessary if toolbox-devvit's lockfile already reflects that the optional dependencies were skipped initially? maintaining this might be tricky

@eritbh eritbh added enhancement New feature or request dependencies Pull requests that update a dependency file toolbox-storage labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file enhancement New feature or request toolbox-storage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant