From 97c522517c5dc631d77f035f0c5ae089ba0068aa Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 2 Jun 2023 04:01:25 -0700 Subject: Fixes #3161 (#3174) * Fixes #3161 * Fix the error message * woops --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/js/builtins/ImportMetaObject.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/js/builtins/ImportMetaObject.ts') diff --git a/src/js/builtins/ImportMetaObject.ts b/src/js/builtins/ImportMetaObject.ts index 2df0f0c98..7fc8b5fe8 100644 --- a/src/js/builtins/ImportMetaObject.ts +++ b/src/js/builtins/ImportMetaObject.ts @@ -33,8 +33,15 @@ export function loadCJS2ESM(this: ImportMetaObject, resolvedSpecifier: string) { if (state === $promiseStatePending || (reactionsOrResult && $isPromise(reactionsOrResult))) { throw new TypeError(`require() async module "${key}" is unsupported`); } else if (state === $promiseStateRejected) { - // TODO: use SyntaxError but preserve the specifier - throw new TypeError(`${reactionsOrResult?.message ?? "An error occurred"} while parsing module \"${key}\"`); + if (!reactionsOrResult?.message) { + throw new TypeError( + `${ + reactionsOrResult + "" ? reactionsOrResult : "An error occurred" + } occurred while parsing module \"${key}\"`, + ); + } + + throw reactionsOrResult; } entry.module = module = reactionsOrResult; } else if (moduleRecordPromise && !module) { -- cgit v1.2.3