Skip to content

Add Zstandard compression support to @tootallnate/zstd-wasm + CI#38

Merged
TooTallNate merged 2 commits into
mainfrom
add-zstd-wasm-compression
Jun 16, 2026
Merged

Add Zstandard compression support to @tootallnate/zstd-wasm + CI#38
TooTallNate merged 2 commits into
mainfrom
add-zstd-wasm-compression

Conversation

@TooTallNate

@TooTallNate TooTallNate commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

Adds compression support to @tootallnate/zstd-wasm (previously decode-only) and introduces a CI workflow that builds and tests the monorepo.

Compression

  • Rebuilt the vendored WASM from upstream zstd 1.5.7's full single-file library (encoder + decoder) instead of the decoder-only amalgamation. Generated via upstream's combine.py, still compiled with wasi-sdk with no WASI imports, multithreading disabled, error strings stripped. Resulting zstd.wasm is ~546 KB (was ~136 KB).
  • New public API, mirroring the existing decoder shape:
    • ZstdEncoder — low-level streaming encoder (push(chunk, onOutput) / finish(onOutput) / encode(plain)).
    • ZstdCompressStreamTransformStream mirroring the platform CompressionStream; finalizes the frame on close.
    • compressBytes(wasm, plain, level?) — one-shot helper.
    • DEFAULT_COMPRESSION_LEVEL (3); compression level (1–22) configurable on all three entry points.
  • C wrapper gains cctx_new/cctx_free, cctx_set_level, compress_stream (ZSTD_compressStream2 with an endOp directive), and cstream_{in,out}_size.
  • Added a changeset (minor).

CI

  • New .github/workflows/ci.yml runs pnpm build + pnpm test across the monorepo on pushes to main and on PRs.
  • Mirrors the release workflow's setup (pnpm, Node 24, frozen lockfile). Installs the system zstd binary, which the new tests use to cross-validate WASM-produced frames. Uses the checked-in WASM binaries (native build steps fall back to committed artifacts when the toolchain is absent), so no wasi-sdk download is needed.

Drive-by fix

  • @tootallnate/bffnt and @tootallnate/dds declared a test script (vitest run) but ship no test files, so vitest exited 1. Added --passWithNoTests to both (matching the existing ffmpeg-wasm convention) so the new CI is green.

Testing

  • packages/zstd-wasm: 16/16 tests pass (5 existing decode + 11 new compression), including cross-validation against system zstd v1.5.7, 4 MB roundtrips, compression-level monotonicity, empty inputs, and stream chaining.
  • Full pnpm build + pnpm test is green across the monorepo (153/153 turbo tasks).

Rebuild the WASM from upstream zstd 1.5.7's full single-file library
(encoder + decoder) instead of the decoder-only amalgamation, and add
encode-side bindings mirroring the existing decoder API:

  - ZstdEncoder         low-level streaming encoder (push/finish/encode)
  - ZstdCompressStream  CompressionStream-shaped TransformStream
  - compressBytes       one-shot helper
  - DEFAULT_COMPRESSION_LEVEL (3); level (1-22) configurable everywhere

The C wrapper gains cctx_new/free, cctx_set_level, compress_stream
(ZSTD_compressStream2 with an endOp directive), and cstream_{in,out}_size.
The build still uses wasi-sdk with no WASI imports; multithreading is
disabled and error strings stripped to match the prior build.

Also add a CI workflow (.github/workflows/ci.yml) that builds and tests
the monorepo on pushes and PRs. It installs the system `zstd` binary
(the new tests cross-validate WASM output against it) and relies on the
checked-in WASM binaries, matching the release workflow's setup.
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nro-editor Ready Ready Preview, Comment Jun 16, 2026 10:08pm
nsp-forwarder Ready Ready Preview, Comment Jun 16, 2026 10:08pm
nx-archive Ready Ready Preview, Comment Jun 16, 2026 10:08pm
rom-id Ready Ready Preview, Comment Jun 16, 2026 10:08pm

@changeset-bot

changeset-bot Bot commented Jun 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 34845d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tootallnate/zstd-wasm Minor
nx-archive Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Both packages declared a `test` script (`vitest run`) but ship no test
files, so vitest exited 1 and broke the new monorepo CI. Add
`--passWithNoTests`, matching the existing ffmpeg-wasm convention, so
turbo's `test` task is a no-op until real tests are added.
@TooTallNate TooTallNate changed the title Add Zstandard compression support to @tootallnate/zstd-wasm + CI Add Zstandard compression support to @tootallnate/zstd-wasm + CI Jun 16, 2026
@TooTallNate TooTallNate merged commit 9359d23 into main Jun 16, 2026
7 checks passed
@TooTallNate TooTallNate deleted the add-zstd-wasm-compression branch June 16, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant