fix(compat): cjs/esm interop for dynamic imports (#13792)

This commit fixes CJS/ESM interop in compat mode for dynamically
imported modules.

"ProcState::prepare_module_load" was changed to accept a list
of "graph roots" without associated "module kind". That module kind
was always hardcoded to "ESM" which is not true for CJS/ESM interop -
a CommonJs module might be imported using "import()" function. In
such case the root of the graph should have "CommonJs" module kind
instead of "ESM".
This commit is contained in:
Bartek Iwańczuk 2022-03-11 02:33:02 +01:00 committed by GitHub
parent 8db3a9546b
commit 808f797633
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 11 deletions

View file

@ -108,7 +108,7 @@ impl ModuleLoader for CliModuleLoader {
async move {
ps.prepare_module_load(
vec![(specifier, deno_graph::ModuleKind::Esm)],
vec![specifier],
is_dynamic,
lib,
root_permissions,