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

feat: support string concat in dynamic import analysis #251

Merged
merged 1 commit into from
May 30, 2024
Merged

Conversation

lucacasonato
Copy link
Member

import("./foo/" + value) is now supported in addition to import(`./foo/${value}`).

`import("./foo/" + value)` is now supported in addition to ``import(`./foo/${value}`)``.
Comment on lines +303 to +305
let cooked = tpl.quasis[i].cooked.as_ref().unwrap();
if cooked.len() > 0 {
parts.push(DynamicTemplatePart::String(cooked.clone()));
Copy link
Member Author

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.

Copy link
Member

@dsherret dsherret left a 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);
Copy link
Member

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?

Copy link
Member

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.

@dsherret dsherret merged commit dc3a3af into main May 30, 2024
2 checks passed
@dsherret dsherret deleted the string_concat branch May 30, 2024 16:18
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.

3 participants