Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno_core::JsRuntime should have separate method for executing "non-main" module #10803

Closed
bartlomieju opened this issue May 31, 2021 · 0 comments · Fixed by #12128
Closed

deno_core::JsRuntime should have separate method for executing "non-main" module #10803

bartlomieju opened this issue May 31, 2021 · 0 comments · Fixed by #12128
Assignees
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed

Comments

@bartlomieju
Copy link
Member

In test_runner.rs there's:

let execute_result = worker.execute_module(&main_module).await;
execute_result?;
worker.execute("window.dispatchEvent(new Event('load'))")?;
let execute_result = worker.execute_module(&test_module).await;
execute_result?;

This leads to a quirk where both main_module and test_module would return true if import.meta.main was checked inside those modules. This is a bug in module loading implementation in deno_core, where JsRuntime::execute_module() treats entry-point as a "main" module.

This should be fixed by providing a second method (JsRuntime::execute_main_module()) that should be used for top-level module and JsRuntime::execute_module() should be used for executing other modules that are not top-level.

@bartlomieju bartlomieju self-assigned this May 31, 2021
@bartlomieju bartlomieju added bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed labels May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant