-
-
Notifications
You must be signed in to change notification settings - Fork 383
fix: avoid bundler warning for getCurrentInstance compatibility
#2337
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
base: v11
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
getCurrentInstance compatibility
Deploying vue-i18n-next with
|
| Latest commit: |
d0b883b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://236cf01d.vue-i18n-next.pages.dev |
| Branch Preview URL: | https://fix-bundler-warning.vue-i18n-next.pages.dev |
@intlify/core
@intlify/core-base
@intlify/devtools-types
@intlify/message-compiler
petite-vue-i18n
@intlify/shared
vue-i18n
@intlify/vue-i18n-core
commit: |
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.
Pull request overview
This PR attempts to fix bundler warnings related to getCurrentInstance compatibility by modifying the approach used to access the currentInstance property from the Vue namespace. The change replaces string concatenation ('current' + 'Instance') with a constant variable (const key = 'currentInstance') to avoid bundler static analysis.
Key Changes:
- Replaced string concatenation trick with a constant variable assignment for accessing
currentInstance - Removed the inline comment explaining the bundler avoidance technique
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // NOTE(kazupon): avoid bundler static analysis | ||
| const name = 'current' + 'Instance' | ||
| return (Vue as any)[name] as GenericComponentInstance | null | ||
| const key = 'currentInstance' |
Copilot
AI
Dec 14, 2025
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.
The new approach using const key = 'currentInstance' may not effectively avoid bundler static analysis warnings. Modern bundlers perform constant folding and can still detect this pattern. The previous string concatenation approach ('current' + 'Instance') was more effective at preventing static analysis because bundlers typically don't evaluate runtime string operations. Consider using a more robust approach such as computed property access or keeping the string concatenation method if the goal is to prevent bundler warnings.
| const key = 'currentInstance' | |
| const key = 'current' + 'Instance' |
fix #2322 #2334