-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esm: exit the process with an error if loader has an issue
Previously, this would trigger an unhandled rejection that the user cannot handle. Fixes: #30205 PR-URL: #30219 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
- Loading branch information
1 parent
7e1f050
commit bd82adb
Showing
5 changed files
with
43 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Flags: --experimental-modules --experimental-loader i-dont-exist | ||
import '../common/index.mjs'; | ||
console.log('This should not be printed'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(node:*) ExperimentalWarning: The ESM module loader is experimental. | ||
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time | ||
internal/modules/esm/default_resolve.js:* | ||
let url = moduleWrapResolve(specifier, parentURL); | ||
^ | ||
|
||
Error: Cannot find package 'i-dont-exist' imported from * | ||
at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:*:*) | ||
at Loader.resolve (internal/modules/esm/loader.js:*:*) | ||
at Loader.getModuleJob (internal/modules/esm/loader.js:*:*) | ||
at Loader.import (internal/modules/esm/loader.js:*:*) | ||
at internal/process/esm_loader.js:*:* | ||
at Object.initializeLoader (internal/process/esm_loader.js:*:*) | ||
at runMainESM (internal/bootstrap/pre_execution.js:*:*) | ||
at Function.Module.runMain (internal/modules/cjs/loader.js:*:*) | ||
at internal/main/run_main_module.js:*:* { | ||
code: 'ERR_MODULE_NOT_FOUND' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Flags: --experimental-modules --experimental-loader ./test/fixtures/es-module-loaders/syntax-error.mjs | ||
import '../common/index.mjs'; | ||
console.log('This should not be printed'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(node:*) ExperimentalWarning: The ESM module loader is experimental. | ||
(node:*) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time | ||
file://*/test/fixtures/es-module-loaders/syntax-error.mjs:2 | ||
await async () => 0; | ||
^^^^^ | ||
|
||
SyntaxError: Unexpected reserved word | ||
at Loader.moduleStrategy (internal/modules/esm/translators.js:*:*) | ||
at async link (internal/modules/esm/module_job.js:*:*) |