From 42af3bef14060969f3a1acbd1fb370717bcd74de Mon Sep 17 00:00:00 2001 From: koooge Date: Sun, 16 Feb 2025 01:17:36 +0100 Subject: [PATCH] sea: suppress builtin warning with disableExperimentalSEAWarning option Signed-off-by: koooge --- lib/internal/main/embedding.js | 3 ++- test/fixtures/sea.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/internal/main/embedding.js b/lib/internal/main/embedding.js index e547e77e9090df..93aa8bb38a06a6 100644 --- a/lib/internal/main/embedding.js +++ b/lib/internal/main/embedding.js @@ -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' + diff --git a/test/fixtures/sea.js b/test/fixtures/sea.js index 6dea6960997feb..65bb8d37e019a2 100644 --- a/test/fixtures/sea.js +++ b/test/fixtures/sea.js @@ -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');