Skip to content

Commit 8777f7f

Browse files
committed
Node.js: remove the build-from-source install fallback
The slint-ui package had an npm install lifecycle script (build-on-demand.mjs) that built the native module from source when no prebuilt binary loaded. pnpm >= 10 ignores dependency build scripts and newer versions fail the installation over them (ERR_PNPM_IGNORED_BUILDS), even though the prebuilt binary was installed just fine via optionalDependencies and resolved at require-time. Remove the fallback: drop the install script and its helper, and move @napi-rs/cli to devDependencies - it was a runtime dependency only so the fallback's build could find the napi binary in a consumer's node_modules. The registry e2e test asserts that pnpm installs slint-ui without ignored build scripts.
1 parent 132d634 commit 8777f7f

7 files changed

Lines changed: 27 additions & 43 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ All notable changes to this project are documented in this file.
8686
- exposed StyledText markdown parsing API.
8787
- Added `ArrayModel.splice` to remove and/or insert values at a given index, following the semantics of `Array.prototype.splice`.
8888
- Added public API to create `keys`
89+
- `npm install slint-ui` no longer falls back to building from source when no pre-built binary matches the
90+
platform; the install script that did this made pnpm >= 10 fail the installation.
8991

9092
### Python
9193

api/node/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,14 @@ Slint is available via NPM, so you can install by running the following command:
3030
npm install slint-ui
3131
```
3232

33-
### Dependencies
33+
This requires **[Node.js](https://nodejs.org/download/release/)** (v20 or newer). Pre-built binaries are
34+
included for Linux (x86-64 and ARM64, glibc), macOS (ARM64), and Windows (x86-64 and ARM64).
3435

35-
You need to install the following components:
36+
### Building from Source
37+
38+
On platforms without pre-built binaries, build Slint-node from a checkout of this repository by running
39+
`pnpm install && pnpm build` in `api/node`. You need to install the following components:
3640

37-
* **[Node.js](https://nodejs.org/download/release/)** (v20 or newer)
3841
* **[pnpm](https://www.pnpm.io/)**
3942
* **[Rust compiler](https://www.rust-lang.org/tools/install)**
4043

api/node/__test__/registry/e2e.test.mts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,15 @@ async function binaryInstalled(dir: string): Promise<boolean> {
277277
for (const pm of ["npm", "pnpm"] as const) {
278278
test(`${pm}: installing slint-ui pulls in the binary and loads`, async () => {
279279
const dir = await consumerProject(`${pm}-prod`);
280-
await install(pm, dir, [`slint-ui@${VERSION}`]);
280+
const { stdout, stderr } = await install(pm, dir, [
281+
`slint-ui@${VERSION}`,
282+
]);
283+
// pnpm >= 10 ignores dependency build scripts and (in newer versions)
284+
// fails the install over them; slint-ui must not have any.
285+
assert.ok(
286+
!`${stdout}${stderr}`.includes("Ignored build scripts"),
287+
"the install must not trip over ignored build scripts",
288+
);
281289
// The matching platform binary package is installed automatically…
282290
assert.ok(
283291
await binaryInstalled(dir),

api/node/build-on-demand.mjs

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

api/node/cover.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ To use Slint with Deno, ensure the following programs are installed:
3030

3131
### Building from Source
3232

33-
Slint-node comes with pre-built binaries for macOS, Linux, and Windows. If you'd like to use Slint-node on a system
34-
without pre-built binaries, you need to additional software:
33+
Slint-node comes with pre-built binaries for Linux (x86-64 and ARM64, glibc), macOS (ARM64), and
34+
Windows (x86-64 and ARM64). On other systems, installing the `slint-ui` package succeeds, but loading it
35+
fails because no matching binary is found. `npm install` does not build Slint-node from source automatically;
36+
instead, build it yourself from a checkout of the [Slint repository](https://github.com/slint-ui/slint)
37+
(run `pnpm install && pnpm build` in `api/node`). This requires:
3538

39+
* **[pnpm](https://www.pnpm.io/)**
3640
* **[Rust compiler](https://www.rust-lang.org/tools/install)**
3741
* Depending on your operating system, you may need additional components. For a list of required system libraries,
3842
see <https://github.com/slint-ui/slint/blob/master/docs/building.md#prerequisites>.

api/node/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"description": "Slint is a declarative GUI toolkit to build native user interfaces for desktop and embedded applications.",
2222
"devDependencies": {
2323
"@biomejs/biome": "catalog:",
24+
"@napi-rs/cli": "3.7.0",
2425
"@types/capture-console": "1.0.5",
2526
"@types/node": "catalog:",
2627
"capture-console": "1.0.2",
@@ -40,7 +41,6 @@
4041
"build:minimal": "napi build --platform --js rust-module.cjs --dts rust-module.d.cts -c binaries.json --no-default-features",
4142
"build:debug": "napi build --platform --js rust-module-dev.cjs --dts rust-module.d.cts -c binaries-dev.json --features system-testing,mcp && pnpm compile",
4243
"build:testing": "napi build --platform --js rust-module.cjs --dts rust-module.d.cts -c binaries.json --features testing && pnpm compile",
43-
"install": "node build-on-demand.mjs",
4444
"docs": "pnpm build && pnpm -C ../../docs/nodejs run build",
4545
"docs:dev": "pnpm build && pnpm -C ../../docs/nodejs run dev",
4646
"docs:debug": "pnpm build:debug && pnpm -C ../../docs/nodejs run build",
@@ -50,8 +50,5 @@
5050
"lint": "biome lint",
5151
"lint:fix": "biome lint --fix",
5252
"test": "vitest run"
53-
},
54-
"dependencies": {
55-
"@napi-rs/cli": "3.7.0"
5653
}
5754
}

pnpm-lock.yaml

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)