aboutsummaryrefslogtreecommitdiff
path: root/src/js/builtins/Module.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-08-21 21:11:27 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-21 21:11:27 -0700
commitbca1bcf29c3bf925299b89dc75523c65549ca1fb (patch)
tree05cebf98510c9d9599504b611be954e8fa0d25a7 /src/js/builtins/Module.ts
parent9027484ae1a9eaf9769d79828db48de66450a3fc (diff)
downloadbun-bca1bcf29c3bf925299b89dc75523c65549ca1fb.tar.gz
bun-bca1bcf29c3bf925299b89dc75523c65549ca1fb.tar.zst
bun-bca1bcf29c3bf925299b89dc75523c65549ca1fb.zip
import errors have `code` set to `ERR_MODULE_NOT_FOUND` and `require` errors have `code` set to `MODULE_NOT_FOUND` (#4244)
* ResolveMessage * Fix it --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/js/builtins/Module.ts')
-rw-r--r--src/js/builtins/Module.ts12
1 files changed, 1 insertions, 11 deletions
diff --git a/src/js/builtins/Module.ts b/src/js/builtins/Module.ts
index ca7c0fa91..d6ebc8578 100644
--- a/src/js/builtins/Module.ts
+++ b/src/js/builtins/Module.ts
@@ -82,17 +82,7 @@ export function require(this: CommonJSModuleRecord, id: string) {
}
export function requireResolve(this: string | { path: string }, id: string) {
- // This try catch is needed because err.code on ESM resolves is ERR_MODULE_NOT_FOUND
- // while in require.resolve this error code is only MODULE_NOT_FOUND.
- // `local-pkg` will check for .code's exact value, and log extra messages if we don't match it.
- try {
- return $resolveSync(id, typeof this === "string" ? this : this?.path, false);
- } catch (error) {
- var e = new Error(`Cannot find module '${id}'`);
- e.code = "MODULE_NOT_FOUND";
- // e.requireStack = []; // TODO: we might have to implement this
- throw e;
- }
+ return $resolveSync(id, typeof this === "string" ? this : this?.path, false);
}
export function requireNativeModule(id: string) {