Skip to content

Commit e1bad54

Browse files
committed
Remove install script, building from source is now opt-in
The vast majority of people don't need this. Package managers are (correctly) starting to block install scripts by default, so this change should reduce install-time warnings.
1 parent 1a2c1c8 commit e1bad54

File tree

7 files changed

+17
-45
lines changed

7 files changed

+17
-45
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
src/build
22
src/node_modules
33
node_modules
4-
/coverage
54
npm/*/*
65
!npm/*/package.json
76
test/bench/node_modules
87
test/fixtures/output*
98
test/fixtures/vips-properties.xml
109
test/leak/libvips.supp
1110
.DS_Store
12-
.nyc_output
1311
.vscode/
1412
package-lock.json
1513
.idea

docs/src/content/docs/changelog/v0.35.0.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ title: v0.35.0 - TBC
33
slug: changelog/v0.35.0
44
---
55

6-
* Upgrade to libvips v8.18.0 for upstream bug fixes.
6+
* Breaking: Drop support for Node.js 18, now requires Node.js >= 20.9.0.
7+
8+
* Breaking: Remove `install` script from `package.json` file.
9+
Compiling from source is now opt-in via the `build` script.
710

8-
* Drop support for Node.js 18, now requires Node.js >= 20.9.0.
11+
* Upgrade to libvips v8.18.0 for upstream bug fixes.
912

1013
* Add `withGainMap` to process HDR JPEG images with embedded gain maps.
1114
[#4314](https://github.com/lovell/sharp/issues/4314)

docs/src/content/docs/install.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ npm install sharp
2020
pnpm add sharp
2121
```
2222

23-
When using `pnpm`, add `sharp` to
24-
[ignoredBuiltDependencies](https://pnpm.io/settings#ignoredbuiltdependencies)
25-
to silence warnings.
26-
2723
```sh frame="none"
2824
yarn add sharp
2925
```
@@ -112,13 +108,13 @@ and on macOS when running Node.js under Rosetta.
112108

113109
## Building from source
114110

115-
This module will be compiled from source when:
116-
117-
* a globally-installed libvips is detected, or
118-
* using `npm explore sharp -- npm run build`, or
119-
* using the deprecated `npm run --build-from-source` at `npm install` time.
111+
```sh frame="none"
112+
npm install sharp
113+
npm explore sharp -- npm run build
114+
```
120115

121-
The logic to detect a globally-installed libvips can be skipped by setting the
116+
The build process will search for a globally-installed libvips.
117+
This detection logic can be skipped by setting the
122118
`SHARP_IGNORE_GLOBAL_LIBVIPS` (never try to use it) or
123119
`SHARP_FORCE_GLOBAL_LIBVIPS` (always try to use it, even when missing or outdated)
124120
environment variables.
@@ -129,21 +125,12 @@ Building from source requires:
129125
* [node-addon-api](https://www.npmjs.com/package/node-addon-api) version 7+
130126
* [node-gyp](https://github.com/nodejs/node-gyp#installation) version 9+ and its dependencies
131127

132-
There is an install-time check for these dependencies.
133128
If `node-addon-api` or `node-gyp` cannot be found, try adding them via:
134129

135130
```sh frame="none"
136131
npm install --save node-addon-api node-gyp
137132
```
138133

139-
When using `pnpm`, you may need to add `sharp` to
140-
[onlyBuiltDependencies](https://pnpm.io/settings#onlybuiltdependencies)
141-
to ensure the installation script can be run.
142-
143-
For cross-compiling, the `--platform`, `--arch` and `--libc` npm flags
144-
(or the `npm_config_platform`, `npm_config_arch` and `npm_config_libc` environment variables)
145-
can be used to configure the target environment.
146-
147134
## WebAssembly
148135

149136
Experimental support is provided for runtime environments that provide
@@ -166,10 +153,8 @@ as well as the additional [building from source](#building-from-source) dependen
166153

167154
```sh frame="none"
168155
pkg install -y pkgconf vips
169-
```
170-
171-
```sh frame="none"
172-
cd /usr/ports/graphics/vips/ && make install clean
156+
npm install sharp
157+
npm explore sharp -- npm run build
173158
```
174159

175160
## Linux memory allocator

install/build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const {
1010
spawnRebuild,
1111
} = require('../lib/libvips');
1212

13-
log('Attempting to build from source via node-gyp');
13+
log('Building from source');
1414
log('See https://sharp.pixelplumbing.com/install#building-from-source');
1515

1616
try {
@@ -29,7 +29,7 @@ try {
2929
}
3030

3131
if (useGlobalLibvips(log)) {
32-
log(`Detected globally-installed libvips v${globalLibvipsVersion()}`);
32+
log(`Found globally-installed libvips v${globalLibvipsVersion()}`);
3333
}
3434

3535
const status = spawnRebuild();

install/check.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/sharp.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ if (sharp) {
7373
} else {
7474
help.push(
7575
`- Manually install libvips >= ${minimumLibvipsVersion}`,
76+
' See https://sharp.pixelplumbing.com/install#building-from-source',
7677
'- Add experimental WebAssembly-based dependencies:',
7778
' npm install --cpu=wasm32 sharp',
7879
' npm install @img/sharp-wasm32'

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@
9393
],
9494
"scripts": {
9595
"build": "node install/build.js",
96-
"install": "node install/check.js || npm run build",
97-
"clean": "rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",
96+
"clean": "rm -rf src/build/ test/fixtures/output.*",
9897
"test": "npm run lint && npm run test-unit",
9998
"lint": "npm run lint-cpp && npm run lint-js && npm run lint-types",
10099
"lint-cpp": "cpplint --quiet src/*.h src/*.cc",

0 commit comments

Comments
 (0)