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(compiler-sfc): analyze import usage in template via AST #9729

Merged
merged 3 commits into from
Dec 1, 2023

Conversation

yyx990803
Copy link
Member

Use proper AST analysis to perform import usage check.

close #8897
close nuxt/nuxt#22416

This PR also adds two new parser options (both are already transform options, they just now also apply to the parser):

  • prefixIdentifiers
  • expressionPlugins

When enabled, SimpleExpression and CompoundExpression nodes now also has an ast property attached, which is the Babel AST parsed from the original JS expression. During the transform phase, transformExpression will reuse the ASTs if they are already present on expression nodes.

SFCParseOptions from @vue/compiler-sfc now also gets a new parseExpressions: boolean option. Since this is required for the new import usage check to work, it is enabled by default. The only case where you'd want to disable it is when you are using the parse method from @vue/compiler-sfc for non-compilation purposes (e.g. just to get the blocks of the SFC) and want to avoid the Babel parse overhead.

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.

1 participant