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

fix(nuxt): use parser to treeshake client-only declarations #18951

Merged
merged 21 commits into from
Feb 16, 2023

Conversation

huang-julien
Copy link
Member

@huang-julien huang-julien commented Feb 10, 2023

πŸ”— Linked issue

Resolve #18949

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Hi πŸ‘‹ ,
Using a regex to treeshake a variable declaration of a component isn't enough. This PR will use the parser to treeshake variables declarations of components that are only called client-side.

Done:

  • identifiers

To do :

  • ObjectExpression
  • AssignmentPattern
  • ArrayPattern
  • Don't remove if it is called in the setup
  • Refactor to make the plugin more readable
  • add test .client components slots treeshaking

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Feb 10, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@huang-julien huang-julien marked this pull request as ready for review February 15, 2023 23:22
@huang-julien
Copy link
Member Author

I think this PR should be ready now. Also the plugin is ... "a bit more readable". If there's anything to add, please let me know πŸ™‚

@huang-julien huang-julien marked this pull request as draft February 16, 2023 08:11
@huang-julien huang-julien marked this pull request as ready for review February 16, 2023 08:18
@danielroe danielroe mentioned this pull request Feb 16, 2023
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you - this is a nice improvement ❀️

@danielroe danielroe changed the title fix(nuxt): use parser to treeshake variable declaration instead of Regex fix(nuxt): use parser to treeshake client-only declarations Feb 16, 2023
@danielroe danielroe merged commit 61cd6b5 into nuxt:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClientOnly treeshake error with async components
2 participants