mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
sea: suppress builtin warning with disableExperimentalSEAWarning option
Signed-off-by: koooge <koooooge@gmail.com> PR-URL: https://github.com/nodejs/node/pull/57086 Refs: https://github.com/nodejs/single-executable/issues/107 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
0a4572d6a7
commit
6fe0723e40
2 changed files with 3 additions and 2 deletions
|
@ -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' +
|
||||
|
|
2
test/fixtures/sea.js
vendored
2
test/fixtures/sea.js
vendored
|
@ -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue