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
feat: support analysis of require()
statements
#69
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did a quick skim through and it's looking good to me.
require()
statementsrequire()
statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only one nitpick. I think we should wait on upgrade to deno_ast
before landing this PR (denoland/deno_ast#46)
impl Default for DependencyKind { | ||
fn default() -> Self { | ||
Self::Import | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it required to implement Default
trait for this enum? It feels to me like a potential footgun that might lead to discrepancies by too liberal use of Default::default()
somewhere in the call chain.
@kitsonk is there anything I can do to help you to land this PR? |
It needs quite a bit of rebasing... let me take care of it. We just didn't need it before, now there is a compelling need. |
Stale and uneeded. |
Closes #58
The PR allows the
deno_graph
to statically analyserequire()
statements in modules and have them exist as part of the module graph. There are some limitations, which are swc limitations:require()
symbol in code and does not track re-assignment. Meaning it won't find dependencies likeconst r = require; const b = r("b");
.require()
function, therefore things likeconst m = "m"; require(m);
do not work.This is a BREAKING CHANGE on the Rust side, but one that shouldn't impact any of the CLI functionality. Essentially
Resolver::resolve()
andLoader::load()
now take an extra argument which indicates what kind of dependency it is. This allows consumers to be able to branch logic in code based on the "reason" the resolution or loading is occurring. On the JavaScript side, it is a non-breaking change, since excess arguments are ignorable.