Skip to content

Initiative: Single Executable Application #75

Open
@jesec

Description

@jesec

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:

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. (and vm.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 in options.
  • 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
  • Creation of the executable?
    • node compile is not planned, yet.

Edge cases:


Proof of concept (nodejs/node#42334 (comment)):

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions