In order to improve startup time, when Atom is built we create a V8 snapshot in which we preload core services and packages. Then, at runtime, we finish loading Atom by supplying all the information we didn't have during the compilation phase (e.g. loading third party packages, custom style sheets, configuration, etc.).
electron-link is the tool that powers snapshots, as it enables us to traverse the entire require graph (starting at the entry point) and replace all the forbidden require
calls (e.g. require calls to native modules, node core modules or other modules that can't be accessed in the snapshot V8 context) with a function that will be called at runtime. When adding new code to Atom, we always try to put it inside the snapshot by, for example, deferring the usage of DOM APIs or native node modules to a later moment in time when those facilities are available. If that is not possible, we will add the unsupported code paths to the list of files that get excluded from the snapshot, ensuring we only exclude those ones that are not supported as opposed to skipping an entire Node module.
The output of electron-link is a single script containing the code for all the modules reachable from the entry point, which we then supply to mksnapshot to generate a snapshot blob.
The generated blob is finally copied into the application bundle and will be automatically loaded by Electron when running Atom.