Open
Description
Continuation of nodejs/node#42334 (comment).
Single Executable Application is one of the technical priorities:
Node.js often loses out to other runtimes/languages in cases where being able to package a single, executable application simplifies distribution and management of what needs to be delivered. While there are components/approaches for doing this, they need to be better documented and evangelized so that this is not seen as a barrier for using Node.js in these situations. This is important to support the expansion of where/when Node.js is used in building solutions.
Prior discussions:
- Next-10 Mini-Summit 18 Nov 2021
- Technical Memo on pkg
- Draft: src,doc: Experimental support for SEA (#42334)
Items (core):
- Make it possible for the embedded script to overlay/override the
fs.*
, including for the internal modules that use them (e.g. loaders).- 3 commits at the moment, and they shouldn't affect functionality in any way.
- Support parsing the header, loading the bake-in Node options, and loading the embedded script.
- Prefer more discussions, especially the parts, when changed later, could be semver-major (e.g. header format).
- We also have to figure out the info to pass to the embedded script (e.g. scriptPos, scriptSize), so the script can use the info to locate the VFS payload. and, how to pass them.
Items:
- Source-less
vm.Script
. (andvm.Module
?)- Involves changes to V8. Need to find an elegant way to bypass bytecode sanity checks in V8 for this case (pkg currently simply removes such checks unconditionally).
- It is a public API, and extra consideration may be necessary. Proposed addition:
sourceless: <boolean> = false
inoptions
.
- More fine-grained way to load a native module from an offset in a file (the executable in our case). Some potential methods have to be implemented in the native (C++) land, so it might be better for Node.js to take over via something like
process.dlopen(...[, offset])
. - Allow post-build swap of intl variants (full-icu, small-icu, system-icu, no-intl).
- No implementation yet, but definitely good-to-have since intl variant has a significant impact on binary size.
- Fully static
linuxstatic
binaries for use cases that require extensive portability (e.g. embedded, industrial).
Out-of-scope, per discussions:
- Virtual file system (VFS)
- The embedded script should do this, and call the user's entrypoint. See pkg.
- Dependency tracing
- Bundling
- Use webpack or others
- Creation of the executable?
node compile
is not planned, yet.
Edge cases:
- Should the SEA behave as the bundled application in all scenarios? Can the user use it as the Node.js runtime if they want to?
Proof of concept (nodejs/node#42334 (comment)):
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
In Progress