Skip to content

sea: suppress builtin warning with disableExperimentalSEAWarning option #57086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading