Auto-build WASM packages on npm install via prepare hook#304
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Thanks! |
|
While the change itself is okay, it's worth noting that this prepare script used to be there before. It was removed deliberately in commit 2fbde38. We should avoid changing this back and forth repeatedly. AFAIUI there are two setups Spark is trying to accommodate: building/developing the project itself and using a specific commit of Spark as dependency in a project. The former requires the user to build the wasm projects. In this case having it part of the In practice people that wanted to test the latest commits ran into issues because they didn't have a Rust toolchain setup. Arguably this negates the convenience of providing pre-built bundles. |
|
@mrxz that totally makes sense. In that case, we should just revert, and update the README, no? |
After cloning the repo and running
npm install, thenpm run buildcommand fails with this error:(fresh clone on osx with cargo 1.94.1 and npm 11.8.0)
The error message suggests a Vite/Rollup config issue, but the real problem is that the
spark-rsandspark-worker-rsWASM packages haven't been built yet. Theirpkg/directories are gitignored (correctly), but nothing in the standard setup flow builds them automatically. You have to know to runnpm run build:wasmfirst, which is only mentioned in the README's build instructions in passing.Fix
This PR sets the
preparescript inpackage.jsontonpm run build:wasm. Thepreparehook runs automatically afternpm install, so the WASM packages are built before anything else needs them. This meansnpm install && npm run buildjust works out of the box for new contributors.The WASM build is only triggered by
npm install— not on everynpm run build— so there's no performance cost during normal development iteration.Verification
rust/spark-rs/pkgandrust/spark-worker-rs/pkgnpm install— verify WASM packages are built automaticallynpm run build— verify it completes successfully