old title: publish npm package with binaries embedded in it instead of using postinstall script
basically:
```
.
├── src/
│ └── main.ts
├── dist/
│ ├── main.js
│ └── main.d.ts
├── bin/
│ ├── typst.win32-x64.exe
│ ├── typst.darwin-x64
│ ├── typst.darwin-arm64
│ ├── typst.linux-x64
│ └── typst.linux-arm64
└── package.json
```
then main.ts/js would run: `typst.${process.platform}-${process.arch}` exe instead of downloading it and then running it. basically skip the download step.
why this might be good:
- no lag for 5s while postinstall or main `ensureInstalled()` downloads and extracts the binary
- could work better offline?
the main win is startup/install time. that's it. HOWEVER this would add considerable size to the published npm package...
```
28M typst-aarch64-apple-darwin/typst
28M typst-aarch64-unknown-linux-musl/typst
29M typst-armv7-unknown-linux-musleabi/typst
30M typst-x86_64-apple-darwin/typst
32M typst-x86_64-pc-windows-msvc/typst.exe
32M typst-x86_64-unknown-linux-musl/typst
```
total ~178M ish
after writing all that text and seeing how large the binaries are when spread across 6x architectures (almost 200mb! when a single platform is only 30mb!) i think the best way to avoid postinstall and speed up install is to use npm-binary-releaser or similar
old title: publish npm package with binaries embedded in it instead of using postinstall script
alternative:
do what https://napi.rs/ does by default and splinter off things into optionalDependencies that only work on a single OS/CPU combo: https://napi.rs/docs/deep-dive/release#3-the-native-addon-for-different-platforms-is-distributed-through-different-npm-packages
ex:
there appears to be a project that is designed to tackle this issue actually and it uses this second approach!
https://github.com/christophwitzko/npm-binary-releaser
after writing all that text and seeing how large the binaries are when spread across 6x architectures (almost 200mb! when a single platform is only 30mb!) i think the best way to avoid postinstall and speed up install is to use npm-binary-releaser or similar