You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But in the case of dynamic import, the above shim can't be used. So err.code needs to be set to ERR_MODULE_NOT_FOUND directly in CLI runtime when --compat flag is specified.
I'm a bit at loss how to tackle this problem right now...
Module loading is done by deno_core and any additional fields on the error instance would need to be created there, but deno_core is completely agnostic of compat layer.
Moreover we need to decide how are we going to handle this situation in wider context - ie. in runtime Deno APIs (ref #12591).
and it has class_name at the creation, but that class_name is not used in core/runtime.rs. I guess we can use that class name and swap the error constructor in core/runtime.rs
(pseudo code)
let value = execute_script(get_custom_error_class(err).unwrap());let err = value.to_object(scope).call_as_constructor(1, err_message);
resolver.reject(scope, err).unwrap();
In Node.js, it's common to check err.code to detect the kind of errors:
std/node
simulates these error codes in API layer (ref: https://github.com/denoland/deno_std/blob/0b31c1647649f9b6aa53432370daab4483803e77/node/_errors.ts#L289-L304 )But in the case of dynamic import, the above shim can't be used. So
err.code
needs to be set toERR_MODULE_NOT_FOUND
directly in CLI runtime when--compat
flag is specified.This feature is used in
mocha
when looking up the test files (ref: https://github.com/mochajs/mocha/blob/97b84708afb42e552cb906a54f9f2aa2e6a98ba4/lib/nodejs/esm-utils.js#L47-L56 )related: #12577
The text was updated successfully, but these errors were encountered: