-
-
Notifications
You must be signed in to change notification settings - Fork 398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace prebuild+prebuild-install with prebuildify #655
Comments
@JoshuaWise I can look into submitting a PR for this if you like. |
I'm interested in developing sqlite solutions where my dev environment is windows and my target environment is Linux (AWS Lambda). For AWS lambda, you basically deploy by zipping up the folder including the code and
Not being to familiar with node-gyp, would the solution above help support this use case of installing prebuilt binaries other than the current host environment into |
@fabiospampinato I'm curious if you have any experience with Electron and prebuildify? I've searched the electron-forge, electron-builder and electron-packager repos for "prebuildify" and didn't find satisfying results. My main question is: how do you not ship all those binaries with your Electron app? E.g. you want to exclude the Windows and macOS binaries from a Linux Electron and vice versa? The prebuildify docs say you use |
@Prinzhorn I mainly work on an Electron app actually, but I don't know too much about prebuildify, I only tried to use that once, in this fork of nsfw and I didn't quite enjoy the experience. Regarding your question I think if you want to have a smaller installation footprint you'll have to manually exclude the artifacts for other platforms when bundling the app for each platform, you can do so with electron-builder, I'm not familiar with forge and packager but I'd imagine they have a similar system. In general I'm not too familiar with using native dependencies in Node, I've found them to be a pain in the ass to work with. Maybe better options could be to use N-API o WASI, but I've no idea how those work. Surely having to download a critical dependency at runtime for your app to work comes with its own downsides though. |
The README for
However, I find this hard to believe when |
I don't know what kind of logic they used to come up with that argument. IMO this proposal isn't an improvement regarding speed of installation but regarding security, every dependency increases the likelihood that at least one of your dependencies will eventually ship malware, and that can be game over. 40+ binaries is indeed a lot, but IMO switching to the safer approach is still totally worth it for the security aspect alone. Still it'd be nice if making the installation more secure didn't require a 40x slowdown. Regarding the number of artifacts:
Which would make downloading all of them a non-problem basically. Optimizing the generation of artifacts can be a pain in the ass though, and maybe that's not doable for some reason, IMO there's a much simpler solution to the problem: let's just publish the *.node files, bypassing tar and gzip entirely, then I can write a drop-in replacement for Obviously non having any dependency that downloads anything at installation-time would be better from a security perspective, but if it's just a tiny dependency, and especially if I'm maintaining it, it's totally ok from my point of view. Does that sound reasonable? |
@fabiospampinato that does sound reasonable. Although, if we're bypassing tar/gzip, the |
An alternative approach to prebuilt binary distribution that may be worth looking at is how esbuild works. I believe what happens is Not sure how well that kind of approach might work with this project but it's interesting for sure.
|
@JoshuaWise I've taken a look at the workflow but that's a can of worm I'd rather not open, I have 0 experience with |
Hi there,
The environment there is just to install fixed packages and but not pre-gyp packages. |
Little update: I'm not longer interested in this, as I think there's just a much simpler approach to the whole problem: just ship the 3 official prebuild binaries for mac/linux/windows (https://www.sqlite.org/download.html) and spawn those directly. It's like 2MB gzipped total with no need to tar/ungzip/prebuild/download anything. |
One downside with that is only the Windows prebuilt binaries come with a 32 bit and 64 bit version, Linux and macOS are |
I think that's somewhat of a problem but at the other end of the spectrum, like macOS can't even run 32bits executables anymore, but there are ARM versions for all those OSes. |
We face the same kind of issue (we can build on various systems, but deploy on linux). For our main DB we use prisma (because of the ORM and the typing), but for additional DBs we want to use Prisma builds binaries for all platforms, and it can be choosed at build time, regardless of the current OS architecture, by setting the right ENV var before installing e.g., in our "production build script", we have I found this quite handy and elegant. It looks like it may eventually help people building electron app too, and I wonder if it could be a valid inspiration. |
Context: I'm trying to prune my dependency tree as much as possible out of security concerns.
This is the dependency tree NPM is giving me for better-sqlite3:
Interestingly this is the same tree without "prebuild-install":
Basically prebuild-install is installing way too much stuff and I'd like to see it removed as a dependency.
On prebuild-install's own readme it says the following:
And in prebuildify's readme it says:
Essentially it seems that a whole lot of code and complexity could be removed just by shipping the prebuild binaries with the package itself rather than requiring an extra download step for them.
For completeness this is the dependency tree I'm getting for prebuildify:
It looks like maybe the tar-fs package could be used instead of the "tar" one to trim down this further.
Potentially I'd be even happier just rebuilding sqlite locally even if that takes a bit longer to install, or with some other solution that manages to keep using prebuild binaries and trims down dependencies further.
I think this package is pretty popular on servers, where each extra dependency you need to install is a bit of a gamble, IMO not strictly necessary dependencies should be removed as much as possible.
The text was updated successfully, but these errors were encountered: