From 808f797633ba82c0e9198481ddd742284a03cb9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 11 Mar 2022 02:33:02 +0100 Subject: 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". --- cli/tests/integration/compat_tests.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cli/tests/integration') diff --git a/cli/tests/integration/compat_tests.rs b/cli/tests/integration/compat_tests.rs index c8fc1c0a0..5c6a93201 100644 --- a/cli/tests/integration/compat_tests.rs +++ b/cli/tests/integration/compat_tests.rs @@ -101,6 +101,12 @@ itest!(cjs_esm_interop { output: "compat/import_cjs_from_esm.out", }); +itest!(cjs_esm_interop_dynamic { + args: + "run --compat --unstable -A --quiet --no-check compat/import_cjs_from_esm/main_dynamic.mjs", + output: "compat/import_cjs_from_esm.out", +}); + #[test] fn globals_in_repl() { let (out, _err) = util::run_and_collect_output_with_args( -- cgit v1.2.3