-
Notifications
You must be signed in to change notification settings - Fork 46
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 string concat in dynamic import analysis #251
Conversation
`import("./foo/" + value)` is now supported in addition to ``import(`./foo/${value}`)``.
let cooked = tpl.quasis[i].cooked.as_ref().unwrap(); | ||
if cooked.len() > 0 { | ||
parts.push(DynamicTemplatePart::String(cooked.clone())); |
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.
@dsherret PTAL - the previous code was incorrect. Raw includes escape sequences in raw form.
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
@@ -308,6 +311,47 @@ impl<'a> Visit for DependencyCollector<'a> { | |||
DynamicArgument::Template(parts) | |||
} | |||
} | |||
Expr::Bin(bin) => { | |||
let mut parts = Vec::with_capacity(2); |
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.
Capacity is not necessarily correct here I think?
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.
Oh, I guess this is just allocating for the common case.
import("./foo/" + value)
is now supported in addition toimport(`./foo/${value}`)
.