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

Importing and requiring a .js file leads to duplicate module evaluation #26438

Closed
dsherret opened this issue Oct 20, 2024 · 1 comment · Fixed by #26439
Closed

Importing and requiring a .js file leads to duplicate module evaluation #26438

dsherret opened this issue Oct 20, 2024 · 1 comment · Fixed by #26439
Labels
bug Something isn't working correctly deno_core Changes in "deno_core" crate are needed

Comments

@dsherret
Copy link
Member

dsherret commented Oct 20, 2024

// main.js
import "./file.js";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);
require("./file.js");

// file.js
let i = 0;
setInterval(() => {
  i++;
  console.log(i);
}, 1_000);

Output:

> deno run -A main.js
1
1
2
2
3
3

Note this works fine when file.js is renamed to file.cjs.

@lucacasonato
Copy link
Member

I think this was also fixed by denoland/deno_core@f217fe0. Let's add a test to CLI when rolling deno_core.

@lucacasonato lucacasonato added the deno_core Changes in "deno_core" crate are needed label Oct 21, 2024
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.

2 participants