Skip to content

perf(install): skip sharp postinstall script for versions >= 0.33#32654

Closed
nathanwhit wants to merge 1 commit intodenoland:mainfrom
nathanwhit:skip-sharp
Closed

perf(install): skip sharp postinstall script for versions >= 0.33#32654
nathanwhit wants to merge 1 commit intodenoland:mainfrom
nathanwhit:skip-sharp

Conversation

@nathanwhit
Copy link
Member

bun does the same thing, but still feels kinda weird

@nathanwhit nathanwhit requested a review from dsherret March 12, 2026 01:13
Comment on lines +208 to +209
if package.id.nv.name == "sharp"
&& package.id.nv.version >= Version::parse_standard("0.33.0").unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. useGlobalLibvips() — whether a system-wide libvips is available
  2. process.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}"
]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nathan noticed that useGlobalLibvips() is slow. I opened lovell/sharp#4505

@dsherret
Copy link
Contributor

Let's close. They're going to improve things: lovell/sharp#4505 (comment)

@dsherret dsherret closed this Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants