I found two errors when playing with various versions of sharp. In one version, ncc compiles correctly but app errors on run, and second, ncc doesn't compile newer sharp version. See examples below.
// src/index.ts (error exists as normal .js file)
import * as sharp from 'sharp';
sharp({
create: {
width: 300,
height: 200,
channels: 4,
background: { r: 255, g: 0, b: 0, alpha: 0.5 }
}
})
.png()
.toBuffer()
.then(console.log)
.catch(console.error);
[email protected] (ncc compiles but can't run function)
Error: dlopen(/Users/jrdn/sharp-example/dist/sharp.node, 1): Library not loaded: @rpath/libvips-cpp.dylib
Referenced from: /Users/jrdn/sharp-example/dist/sharp.node
Reason: image not found
[email protected] (ncc does not compile)
ERROR in ./node_modules/sharp/lib/constructor.js
Module build failed (from (webpack)/ncc/loaders/relocate-loader.js):
Error: Could not locate the bindings file. Tried:
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/build/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/build/Debug/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/build/Release/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/out/Debug/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/Debug/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/out/Release/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/Release/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/build/default/sharp.node
→ /Users/jrdn/sharp-example/node_modules/sharp/lib/compiled/10.4.1/darwin/x64/sharp.node
Thanks @j (nice github username)
I agree this is quite popular and probably a good one to focus on!
Awesome :)
Fixed in 0.6.0
Most helpful comment
Thanks @j (nice github username)
I agree this is quite popular and probably a good one to focus on!