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');