Skip to content

Commit

Permalink
feat(vue 3): migrate from Vue.default.version to a fallback (algolia/…
Browse files Browse the repository at this point in the history
…vue-instantsearch#847)

Co-authored-by: eunjae-lee <[email protected]>
  • Loading branch information
Haroenv and eunjae-lee authored Jun 1, 2021
1 parent c32e06f commit 6bebf9f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/vue-instantsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@
},
"dependencies": {
"algoliasearch-helper": "^3.1.0",
"instantsearch.js": "^4.20.0"
"instantsearch.js": "^4.20.0",
"vue-demi": "npm:@eunjae-lee/[email protected]"
},
"peerDependencies": {
"algoliasearch": ">= 3.32.0 < 5",
"vue": "^2.6.0",
"vue": "^2.6.0 || >=3.0.0-rc.0",
"vue-server-renderer": "^2.6.11"
},
"devDependencies": {
Expand Down Expand Up @@ -114,11 +115,11 @@
"bundlesize": [
{
"path": "./dist/vue-instantsearch.js",
"maxSize": "52.75 kB"
"maxSize": "53.00 kB"
},
{
"path": "./dist/vue-instantsearch.common.js",
"maxSize": "16.25 kB"
"maxSize": "16.50 kB"
}
],
"resolutions": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSuitMixin } from '../mixins/suit';
import { version } from '../../package.json'; // rollup does pick only what needed from json
import { _objectSpread } from './polyfills';
import Vue from 'vue';
import { getVueVersion } from './getVueVersion';

export const createInstantSearchComponent = component =>
_objectSpread(
Expand Down Expand Up @@ -54,7 +54,7 @@ export const createInstantSearchComponent = component =>
created() {
const searchClient = this.instantSearchInstance.client;
if (typeof searchClient.addAlgoliaAgent === 'function') {
searchClient.addAlgoliaAgent(`Vue (${Vue.version})`);
searchClient.addAlgoliaAgent(`Vue (${getVueVersion()})`);
searchClient.addAlgoliaAgent(`Vue InstantSearch (${version})`);
}
},
Expand Down
9 changes: 9 additions & 0 deletions packages/vue-instantsearch/src/util/getVueVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { isVue3, version, Vue2 } from 'vue-demi';

export function getVueVersion() {
if (isVue3) {
return version;
} else {
return Vue2.version;
}
}

0 comments on commit 6bebf9f

Please sign in to comment.