Skip to content

Conversation

brunocroh
Copy link
Member

@brunocroh brunocroh commented Aug 25, 2025

Closes #187

Add support to getNodeImportCalls returns the entire block when found a dynamic import with promise.

like the block below

await import("node:fs").then((mdl) => {
	const readfile = mdl.readFile;
	readfile("foo.txt", "utf8", (err, data) => {
		if (err) throw err;
		console.log(data);
	});
});

This utility function can now return two different types of nodes:

kind: variable_declarator
Indicates that a variable was created in the file scope.

kind: expression_statement
Indicates that it is a dynamic import, and the imported module likely exists only within the scope of the then function.


Support handling imports that use variables as well.

const moduleName= "node:fs";

const fs = await import(moduleName)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(utility): extend getNodeImportCalls to support then methods
2 participants