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

Check global vue config exists before installing vue 2 handler #2171

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

yousif-bugsnag
Copy link
Contributor

@yousif-bugsnag yousif-bugsnag commented Jul 12, 2024

Goal

Fixes an error in the Vue plugin initialisation when using Vue 3+ via CDN (reported in #2150)

Design

Currently the plugin attempts to install the Vue 2 handler (via the global Vue.config) if a global Vue object exists, but CDN builds of Vue 3+ will also expose a global Vue object.

This PR updates the check in plugin load to ensure that Vue.config exists before installing the Vue 2 handler.

Testing

Added a new unit test and tested manually with a Vue 3 CDN build.

@yousif-bugsnag yousif-bugsnag marked this pull request as ready for review July 12, 2024 11:31
Copy link

github-actions bot commented Jul 12, 2024

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 44.21 kB 13.51 kB
After 44.21 kB 13.51 kB
± No change No change

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against 69e59db

@@ -16,7 +16,7 @@ module.exports = class BugsnagPluginVue {
}

load (client) {
if (this.Vue) {
if (this.Vue && this.Vue.config) {
Copy link
Member

Choose a reason for hiding this comment

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

any particular reason not to check against the vue version? we could even use a switch statement to make supporting new versions easier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the global Vue.config was removed in v3, but I just thought it made more sense to check if the required API exists rather than check for a particular version.

Really either way would work - and I guess the plugin is already 'versioned' so happy to change to a version check if you think a would be better.

Copy link
Member

Choose a reason for hiding this comment

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

fair point. API over version. 👍🏻

@yousif-bugsnag yousif-bugsnag merged commit 5b87222 into next Jul 15, 2024
69 checks passed
@yousif-bugsnag yousif-bugsnag deleted the PLAT-12245/vue-3-global-fix branch July 15, 2024 09:30
@gingerbenw gingerbenw mentioned this pull request Aug 27, 2024
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.

2 participants