Skip to content

Commit

Permalink
sea: suppress builtin warning with disableExperimentalSEAWarning option
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
koooge authored and targos committed Feb 24, 2025
1 parent 922ea2f commit f2db69a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/internal/main/embedding.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const { codes: {
prepareMainThreadExecution(false, true);

const isLoadingSea = isSea();
const isBuiltinWarningNeeded = isLoadingSea && isExperimentalSeaWarningNeeded();
if (isExperimentalSeaWarningNeeded()) {
emitExperimentalWarning('Single executable application');
}
Expand Down Expand Up @@ -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' +
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/sea.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit f2db69a

Please sign in to comment.