mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 23:56:58 +00:00

Since SEA is very similar in principle to embedding functionality, it makes sense to share code paths where possible. This commit does so and addresses a `TODO` while doing so. It also adds a utility to directly run CJS code to the embedder startup callback, which comes in handy for this purpose. Finally, this commit is breaking because it aligns the behavior of `require()`ing internal modules; previously, embedders could use the `require` function that they received to do so. (If this is not considered breaking because accessing internals is not covered by the API, then this would need ABI compatibility patches for becoming fully non-breaking.) PR-URL: https://github.com/nodejs/node/pull/46825 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
19 lines
590 B
JavaScript
19 lines
590 B
JavaScript
'use strict';
|
|
const {
|
|
prepareMainThreadExecution,
|
|
markBootstrapComplete,
|
|
} = require('internal/process/pre_execution');
|
|
const { isSea } = internalBinding('sea');
|
|
const { emitExperimentalWarning } = require('internal/util');
|
|
const { embedderRequire, embedderRunCjs } = require('internal/util/embedding');
|
|
const { getEmbedderEntryFunction } = internalBinding('mksnapshot');
|
|
|
|
prepareMainThreadExecution(false, true);
|
|
markBootstrapComplete();
|
|
|
|
if (isSea()) {
|
|
emitExperimentalWarning('Single executable application');
|
|
}
|
|
|
|
return getEmbedderEntryFunction()(embedderRequire, embedderRunCjs);
|