denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.19k stars 5.41k forks source link

Add support for node native addons / napi / FFI in `deno compile` #23266

Open marvinhagemeister opened 7 months ago

marvinhagemeister commented 7 months ago

Discussed in https://github.com/denoland/deno/discussions/23255

Originally posted by **babakfp** April 6, 2024 Hi 👋 https://github.com/parcel-bundler/lightningcss/discussions/712 Based on this comment https://github.com/parcel-bundler/lightningcss/discussions/712#discussioncomment-9029656 and this: ![Screenshot 2024-04-06 223807](https://github.com/denoland/deno/assets/44144724/d10c2985-f70a-489e-9ffd-11f9157b20e3) (I used this library https://deno.land/x/abc@v1.3.3 and when I compiled, it started to download this ^ file). It seems like Deno doesn't do the same for lightningcss.

Search keywords:

bartlomieju commented 7 months ago

I don't expect this to work. FFI/native Node extensions can't be included in the the compiled binary.

AddictArts commented 5 months ago

As a data point I ran into similar with electron-builder and now with deno. For elextron-builder I used asar.upacked which essentially put a node_modules and native within. Seems like deno should or maybe could do the same?

Dmitri-Sintsov commented 4 days ago

I don't expect this to work. FFI/native Node extensions can't be included in the the compiled binary.

Why not? These work with non-compiled source runtime. Anyway, in case these cannot be easily included, maybe the compiler could add these native modules as separate files to load them when running resulting binary? That would be much better than nothing.