sea: suppress builtin warning with disableExperimentalSEAWarning option

Signed-off-by: koooge <koooooge@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/57086
Refs: https://github.com/nodejs/single-executable/issues/107
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
koooge 2025-02-16 01:17:36 +01:00 committed by James M Snell
parent 0a4572d6a7
commit 6fe0723e40
2 changed files with 3 additions and 2 deletions

View file

@ -30,6 +30,7 @@ const { codes: {
prepareMainThreadExecution(false, true);
const isLoadingSea = isSea();
const isBuiltinWarningNeeded = isLoadingSea && isExperimentalSeaWarningNeeded();
if (isExperimentalSeaWarningNeeded()) {
emitExperimentalWarning('Single executable application');
}
@ -98,7 +99,7 @@ let warnedAboutBuiltins = false;
function embedderRequire(id) {
const normalizedId = normalizeRequirableId(id);
if (!normalizedId) {
if (isLoadingSea && !warnedAboutBuiltins) {
if (isBuiltinWarningNeeded && !warnedAboutBuiltins) {
emitWarningSync(
'Currently the require() provided to the main script embedded into ' +
'single-executable applications only supports loading built-in modules.\n' +

View file

@ -10,9 +10,9 @@ const builtinWarning =
To load a module from disk after the single executable application is launched, use require("module").createRequire().
Support for bundled module loading or virtual file systems are under discussions in https://github.com/nodejs/single-executable`;
expectWarning('Warning', builtinWarning); // Triggered by require() calls below.
// This additionally makes sure that no unexpected warnings are emitted.
if (!createdRequire('./sea-config.json').disableExperimentalSEAWarning) {
expectWarning('Warning', builtinWarning); // Triggered by require() calls below.
expectWarning('ExperimentalWarning',
'Single executable application is an experimental feature and ' +
'might change at any time');