Skip to content

Commit ac35106

Browse files
kooogetargos
authored andcommitted
sea: suppress builtin warning with disableExperimentalSEAWarning option
Signed-off-by: koooge <koooooge@gmail.com> PR-URL: #57086 Refs: nodejs/single-executable#107 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent fec2d50 commit ac35106

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/internal/main/embedding.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const { codes: {
3030
prepareMainThreadExecution(false, true);
3131

3232
const isLoadingSea = isSea();
33+
const isBuiltinWarningNeeded = isLoadingSea && isExperimentalSeaWarningNeeded();
3334
if (isExperimentalSeaWarningNeeded()) {
3435
emitExperimentalWarning('Single executable application');
3536
}
@@ -98,7 +99,7 @@ let warnedAboutBuiltins = false;
9899
function embedderRequire(id) {
99100
const normalizedId = normalizeRequirableId(id);
100101
if (!normalizedId) {
101-
if (isLoadingSea && !warnedAboutBuiltins) {
102+
if (isBuiltinWarningNeeded && !warnedAboutBuiltins) {
102103
emitWarningSync(
103104
'Currently the require() provided to the main script embedded into ' +
104105
'single-executable applications only supports loading built-in modules.\n' +

test/fixtures/sea.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const builtinWarning =
1010
To load a module from disk after the single executable application is launched, use require("module").createRequire().
1111
Support for bundled module loading or virtual file systems are under discussions in https://github.com/nodejs/single-executable`;
1212

13-
expectWarning('Warning', builtinWarning); // Triggered by require() calls below.
1413
// This additionally makes sure that no unexpected warnings are emitted.
1514
if (!createdRequire('./sea-config.json').disableExperimentalSEAWarning) {
15+
expectWarning('Warning', builtinWarning); // Triggered by require() calls below.
1616
expectWarning('ExperimentalWarning',
1717
'Single executable application is an experimental feature and ' +
1818
'might change at any time');

0 commit comments

Comments
 (0)