mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-17 10:53:07 +00:00
Fix fallback to source builds
Continue to run build-on-demand.mjs to permit a fallback to a from-source build for users who run `npm install slint-ui` on a platform where we don't provide binaries for (such as linux-armv7/64). However, this is only done when run from the installed package, not from git. From git, the prestart trick remains in use.
This commit is contained in:
parent
0461abfc73
commit
9f7e407eff
8 changed files with 26 additions and 14 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
import { Worker } from "node:worker_threads";
|
import { Worker } from "node:worker_threads";
|
||||||
import { spawn } from "node:child_process";
|
import { spawn } from "node:child_process";
|
||||||
|
import { existsSync } from "node:fs";
|
||||||
|
|
||||||
const worker = new Worker("./rust-module.cjs");
|
const worker = new Worker("./rust-module.cjs");
|
||||||
// Define dummy error handler to prevent node from aborting on errors
|
// Define dummy error handler to prevent node from aborting on errors
|
||||||
|
|
@ -14,9 +15,19 @@ worker.on("error", (error) => {
|
||||||
});
|
});
|
||||||
worker.on("exit", (code) => {
|
worker.on("exit", (code) => {
|
||||||
if (code !== 0) {
|
if (code !== 0) {
|
||||||
console.log("slint-ui: loading rust-module.cjs failed, building now");
|
// HACK: npm package removes .npmignore. If the file is present, then it means that we're in the Slint git repo,
|
||||||
spawn("npm", ["run", "build"], {
|
// and we don't want to automatically build (see https://github.com/slint-ui/slint/pull/6780).
|
||||||
stdio: "inherit",
|
if (existsSync("./.npmignore")) {
|
||||||
});
|
console.log(
|
||||||
|
"slint-ui: loading rust-module.cjs failed, please run `npm run build` first.",
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(
|
||||||
|
"slint-ui: loading rust-module.cjs failed, building now",
|
||||||
|
);
|
||||||
|
spawn("npm", ["run", "build"], {
|
||||||
|
stdio: "inherit",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
"build": "napi build --platform --release --js rust-module.cjs --dts rust-module.d.ts -c binaries.json",
|
"build": "napi build --platform --release --js rust-module.cjs --dts rust-module.d.ts -c binaries.json",
|
||||||
"build:debug": "napi build --platform --js rust-module.cjs --dts rust-module.d.ts -c binaries.json && pnpm compile",
|
"build:debug": "napi build --platform --js rust-module.cjs --dts rust-module.d.ts -c binaries.json && pnpm compile",
|
||||||
"build:testing": "napi build --platform --js rust-module.cjs --dts rust-module.d.ts -c binaries.json --features testing && pnpm compile",
|
"build:testing": "napi build --platform --js rust-module.cjs --dts rust-module.d.ts -c binaries.json --features testing && pnpm compile",
|
||||||
|
"install": "node build-on-demand.mjs",
|
||||||
"docs": "pnpm build && typedoc --hideGenerator --treatWarningsAsErrors --readme cover.md typescript/index.ts",
|
"docs": "pnpm build && typedoc --hideGenerator --treatWarningsAsErrors --readme cover.md typescript/index.ts",
|
||||||
"check": "biome check",
|
"check": "biome check",
|
||||||
"format": "biome format",
|
"format": "biome format",
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node .",
|
"start": "node .",
|
||||||
"prestart": "cd ../../../api/node/ && node build-on-demand.mjs && pnpm compile",
|
"prestart": "cd ../../../api/node/ && pnpm run build && pnpm compile",
|
||||||
"check": "biome check",
|
"check": "biome check",
|
||||||
"format": "biome format",
|
"format": "biome format",
|
||||||
"format:fix": "biome format --write",
|
"format:fix": "biome format --write",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node .",
|
"start": "node .",
|
||||||
"prestart": "cd ../../../api/node/ && node build-on-demand.mjs && pnpm compile"
|
"prestart": "cd ../../../api/node/ && pnpm run build && pnpm compile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node .",
|
"start": "node .",
|
||||||
"prestart": "cd ../../../api/node/ && node build-on-demand.mjs && pnpm compile"
|
"prestart": "cd ../../../api/node/ && pnpm run build && pnpm compile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "tsc --build && node ./main.js",
|
"start": "tsc --build && node ./main.js",
|
||||||
"prestart": "cd ../../../api/node/ && node build-on-demand.mjs && pnpm compile",
|
"prestart": "cd ../../../api/node/ && pnpm run build && pnpm compile",
|
||||||
"type-check": "tsc --noEmit"
|
"type-check": "tsc --noEmit"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node .",
|
"start": "node .",
|
||||||
"prestart": "cd ../../api/node/ && node build-on-demand.mjs && pnpm compile"
|
"prestart": "cd ../../api/node/ && pnpm run build && pnpm compile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node .",
|
"start": "node .",
|
||||||
"prestart": "cd ../../../api/node/ && node build-on-demand.mjs && pnpm compile"
|
"prestart": "cd ../../../api/node/ && pnpm run build && pnpm compile"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue