perf(install): skip sharp postinstall script for versions >= 0.33#32654
perf(install): skip sharp postinstall script for versions >= 0.33#32654nathanwhit wants to merge 1 commit intodenoland:mainfrom
Conversation
| if package.id.nv.name == "sharp" | ||
| && package.id.nv.version >= Version::parse_standard("0.33.0").unwrap() |
There was a problem hiding this comment.
bun does the same thing, but still feels kinda weird
It seems very rude to the maintainer that they do this.
LLM Output
The install script in package.json is needed in the published npm package.
What happens
"install": "node install/check.js || npm run build"When a user runs npm install sharp, npm automatically executes this install lifecycle script.
How it works
install/check.js checks two conditions:
useGlobalLibvips()— whether a system-wide libvips is availableprocess.env.npm_config_build_from_source— whether the user explicitly requested a source build
If either is true, it exits with code 1, causing the fallback npm run build to compile the native addon from source via install/build.js.
Normal case
When prebuilt binaries are available (via @sharp/ platform packages), check.js exits with code 0 and the build step is skipped entirely.
Why it's included
The install directory is explicitly listed in the published files array:
"files": [
"install",
"lib",
"src/*.{cc,h,gyp}"
]There was a problem hiding this comment.
Nathan noticed that useGlobalLibvips() is slow. I opened lovell/sharp#4505
|
Let's close. They're going to improve things: lovell/sharp#4505 (comment) |
bun does the same thing, but still feels kinda weird