diff options
author | 2023-06-02 04:01:25 -0700 | |
---|---|---|
committer | 2023-06-02 04:01:25 -0700 | |
commit | 97c522517c5dc631d77f035f0c5ae089ba0068aa (patch) | |
tree | cbff1047c7438c71d649fee3e9aa8fa398515d71 /src/js/builtins/ImportMetaObject.ts | |
parent | 4c6245b2e5788ac46e31bf67beefab8cdadebedb (diff) | |
download | bun-97c522517c5dc631d77f035f0c5ae089ba0068aa.tar.gz bun-97c522517c5dc631d77f035f0c5ae089ba0068aa.tar.zst bun-97c522517c5dc631d77f035f0c5ae089ba0068aa.zip |
Fixes #3161 (#3174)
* Fixes #3161
* Fix the error message
* woops
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/js/builtins/ImportMetaObject.ts')
-rw-r--r-- | src/js/builtins/ImportMetaObject.ts | 11 |
1 files changed, 9 insertions, 2 deletions
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) { |