Description
The recently landed build-time user-land snapshot is related to packaging solutions (e.g. pkg, nexe) in that if the user puts all the resources (modules, assets) in the snapshot, the compiled binary is a single-executable containing a bundle of user code, similar to what these packaging solutions produce, only that
- We do not provide APIs for the user to specify the run-time entry point in the snapshot entry point yet (it's a WIP), so for now you still have to start the deserialized app with another JS entry point script (i.e. you need to have two files to get it up and running)
- For now with these packaging solutions you'd usually still need to parse/execute some initialization code before the app is up and running, while with snapshots you can simply deserialize an initialized heap and may not have to execute the initialization code.
On the other hand, the user land snapshot we have right now is still a bit limited - a fair amount of builtins are not yet supported (pending more refactoring), and we still need to collect more user feedback to find states in builtins that might be out-of-sync with the system/native layer when being deserialized from the. snapshot. We also do not support user modules yet (the entry point must contain a bundle of all the modules that's needed by the app). In terms of user-experience, it might still be better to have some kind of tooling that allows users to load assets from the binary as if the assets are in the file system (i.e. virtual file system that packaging solutions provides).
I think that user snapshots in Node.js core is not a complete replacement of these packaging solutions (unless we decide to provide an "official" solution ourselves, but still packaging is different from just snapshotting), but rather it's something that packaging solutions can make use of (i.e. they can build a snapshot into the packaged binary too, while providing features like virtual file systems or compression of assets for a better user experience). So this is an issue to gather ideas and feedback, etc.
Refs: #42566