Files
lancedb/nodejs/examples
Will JonesandClaude Opus 5.5 96328f6e08 fix(node): upgrade transformers.js to 4.3.2 to pick up patched sharp (#4885)
## Summary

`@lancedb/lancedb` pins the optional dependency
`@huggingface/transformers` at 3.0.2, which requires `sharp ^0.33.5`.
Every npm install of LanceDB therefore pulled in a sharp version with
critical advisories (GHSA-wq5f-xc86-pv6w, GHSA-rgj7-g3m4-5g8c). No 3.x
release of transformers allows a patched sharp, so this upgrades to
4.3.2, which requires `sharp ^0.35.4`. A fresh install resolves that
range to 0.35.5, the first release that fixes both advisories.

- `nodejs/package.json`: `@huggingface/transformers` 3.0.2 → 4.3.2.
- `nodejs/pnpm-workspace.yaml`: remove the `sharp: ^0.35.4` override. It
only covered our own install, not consumers, and transformers now
requires that range itself.
- `nodejs/examples`: transformers 3.0.2 → 4.3.2, sharp 0.33.5 → 0.35.5.
- Both lockfiles resolve sharp to 0.35.5; `pnpm audit` reports no sharp
advisories in either.

`TransformersEmbeddingFunction` needed no code changes. The transformers
types are only used in private fields, so the published typings don't
change.

`docs/web-tests/ts` and `docs/web-tests/blob-v2/ts` are left alone: they
resolve transformers through a published `@lancedb/lancedb`, so they
pick this up after a release.

## Evidence

Embeddings from the built-in `huggingface` embedding function (default
`Xenova/all-MiniLM-L6-v2`) on 4.3.2, compared with the same mean pooling
on 3.0.2, for three sentences:

```
transformers 4.3.2: 3 x 384
text 0: max|diff|=6.62e-07  cosine=1.00000000
text 1: max|diff|=6.26e-07  cosine=1.00000000
text 2: max|diff|=7.33e-07  cosine=1.00000000
```

End to end through a table, `search("a feline sat down")` returns `["The
cat sat on the mat.", "A dog barked at the mailman."]`.

## Merge Risk

**Door:** Two-way. A revert restores the 3.0.2 pin.
**Blast Radius:** Node `huggingface` embedding function, and install
footprint of the optional dependency (onnxruntime-node 1.19.2 → 1.30.0,
which still downloads the CUDA provider on Linux x64 by default, as
1.19.2 did).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 11:07:44 -08:00
..