chore: upgrade sharp to latest v0.35.3#594
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
@lovell I wouldn't expect the special case to be required now that sharp fixed the logic to be statically analyzable here: I think we should figure out the failure mode instead of changing the special case (the special case should just be for old versions of sharp) |
|
The prebuilt sharp packages e.g. For a file to be considered necessary, is it enough to reference that file in the |
|
Typically it needs to be part of a require() or import or readFile() to be statically analyzed and emitted, but there is a bit more nuance. For example this sharedLibEmit() does some magic that might be relevant here: nft/src/utils/sharedlib-emit.ts Line 20 in 7e43ba4 |
|
I had claude try a few different solutions and they were pretty verbose since it tried to parse the One of the solutions was much more simple seen here: However, it feels relatively similar to the special case we already have for sharp here (checking package.json for optionalDependencies), so I'm thinking we might as well merge your PR since its less risk. |
|
How about a possible alternative where the For example, the logic in try { require('@img/sharp-libvips-linux-x64/empty.node') } catch {}This might be enough for the existing |
|
@lovell Yes that would be great! |
1c7aa85 to
6e02aec
Compare
|
I've published a release candidate v0.35.2-rc.2 of sharp with the Marking this PR as draft for now until after v0.35.2 is released and the 2-day new package cool-down has passed. I note the logic in TurboPack is slightly different from the logic in this package as it only has an nft/src/utils/sharedlib-emit.ts Line 16 in 8673d63 |
|
I spoke to the @mischnic on the turbopack team we think require('pkg/stub.node') is probably going to be prone to error. If you know the exact files that need to be included, you could instead do You can test this locally without needing to publish a new version by using |
The special case is no longer required for sharp >= 0.35.2
6e02aec to
4e4e898
Compare
|
I've now updated this PR to the latest sharp v0.35.3, which removes the stub and instead uses For example, the try { require.resolve('@img/sharp-libvips-linux-x64/binary'); } catch {}...and the "exports": {
"./binary": "./lib/libvips-cpp.so.8.18.3"
},This approach works with the built-in (i.e. no special case) logic of the |
styfle
left a comment
There was a problem hiding this comment.
Thanks for all your hard work on sharp!
Extends the sharp "special case" with additional ESM/CJS-specific paths added in v0.35.0.No longer requires the "special case" from 0.35.2 onwards.
The existing path check remains to support older versions
and future-proof for when we switch to ESM-only.