fix: emit libvips shared library for sharp@0.35#595
Open
styfle wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
ijjk
approved these changes
Jun 16, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
sharp@0.35reorganized its prebuilt binaries. The platform package (e.g.@img/sharp-darwin-arm64) loads its native.nodeaddon, which in turn dlopens the libvips shared library (libvips-cpp.*.dylib/.so/.dll) from a sibling package,@img/sharp-libvips-<platform>. Because that load happens inside the compiled binary rather than via a JSrequire, static analysis never saw it, so the shared library was missing from the trace and the bundled app failed at runtime withCannot find module/ dlopen errors.The previous
sharpspecial case keyed onsharp/lib/index.js, whichsharp@0.35moved todist/, so it silently stopped firing.Fix
Two complementary mechanisms, covering old and new sharp:
sharedLibEmitalready runs whenever a.nodefile is emitted and globs the binary's own package for shared libraries. It now also reads that package'spackage.jsonand emits the shared libraries from eachoptionalDependenciespackage (resolved relative to thenode_modulesroot, withrealpathso pnpm symlink layouts work). This is version-independent: it follows the declared dependency (@img/sharp-libvips-<platform>) rather than hardcoding paths.require(path)over a list of candidate specifiers), so the existingsharpspecial case inspecial-cases.tsis kept for that case, with a clarifying comment.Validation
node out/cli.js print test/integration/sharp.jsnow lists@img/sharp-libvips-<platform>/lib/libvips-cpp.*.pnpm test test/integration.test.jspasses all 89 tests, including:sharp.js(sharp 0.35.1 → manifest path)sharp-pnpm.js(sharp 0.33.2 → special-case path)🤖 Generated with Claude Code