GeezerVison is showing github.com — esm: exit the process with an error if loader has an issue · nodejs/node@bd82adb
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/bootstrap/pre_execution.js +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -480,16 +480,16 @@ function runMainESM(mainPath) { |
480 | 480 | return esmLoader.initializeLoader().then(() => { |
481 | 481 | const main = path.isAbsolute(mainPath) ? |
482 | 482 | pathToFileURL(mainPath).href : mainPath; |
483 | | - return esmLoader.ESMLoader.import(main).catch((e) => { |
484 | | - if (hasUncaughtExceptionCaptureCallback()) { |
485 | | - process._fatalException(e); |
486 | | - return; |
487 | | - } |
488 | | - internalBinding('errors').triggerUncaughtException( |
489 | | - e, |
490 | | - true /* fromPromise */ |
491 | | - ); |
492 | | - }); |
| 483 | + return esmLoader.ESMLoader.import(main); |
| 484 | + }).catch((e) => { |
| 485 | + if (hasUncaughtExceptionCaptureCallback()) { |
| 486 | + process._fatalException(e); |
| 487 | + return; |
| 488 | + } |
| 489 | + internalBinding('errors').triggerUncaughtException( |
| 490 | + e, |
| 491 | + true /* fromPromise */ |
| 492 | + ); |
493 | 493 | }); |
494 | 494 | } |
495 | 495 |
|
|
Collapse file
Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Flags: --experimental-modules --experimental-loader i-dont-exist |
| 2 | +import '../common/index.mjs'; |
| 3 | +console.log('This should not be printed'); |
Collapse file
Copy file name to clipboard +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +(node:*) ExperimentalWarning: The ESM module loader is experimental. |
| 2 | +(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time |
| 3 | +internal/modules/esm/default_resolve.js:* |
| 4 | + let url = moduleWrapResolve(specifier, parentURL); |
| 5 | + ^ |
| 6 | + |
| 7 | +Error: Cannot find package 'i-dont-exist' imported from * |
| 8 | + at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:*:*) |
| 9 | + at Loader.resolve (internal/modules/esm/loader.js:*:*) |
| 10 | + at Loader.getModuleJob (internal/modules/esm/loader.js:*:*) |
| 11 | + at Loader.import (internal/modules/esm/loader.js:*:*) |
| 12 | + at internal/process/esm_loader.js:*:* |
| 13 | + at Object.initializeLoader (internal/process/esm_loader.js:*:*) |
| 14 | + at runMainESM (internal/bootstrap/pre_execution.js:*:*) |
| 15 | + at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) |
| 16 | + at internal/main/run_main_module.js:*:* { |
| 17 | + code: 'ERR_MODULE_NOT_FOUND' |
| 18 | +} |
Collapse file
Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/syntax-error.mjs |
| 2 | +import '../common/index.mjs'; |
| 3 | +console.log('This should not be printed'); |
Collapse file
Copy file name to clipboard +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +(node:*) ExperimentalWarning: The ESM module loader is experimental. |
| 2 | +(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time |
| 3 | +file://*/test/fixtures/es-module-loaders/syntax-error.mjs:2 |
| 4 | +await async () => 0; |
| 5 | +^^^^^ |
| 6 | + |
| 7 | +SyntaxError: Unexpected reserved word |
| 8 | + at Loader.moduleStrategy (internal/modules/esm/translators.js:*:*) |
| 9 | + at async link (internal/modules/esm/module_job.js:*:*) |