Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

Commit

Permalink
feat: make it work with Vue 2
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Nov 30, 2020
1 parent e630455 commit 6571605
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions __tests__/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Vue, { nextTick } from 'vue'
import { nextTick } from 'vue-demi'
import { MockFirebase, MockedReference } from 'firebase-mock'
import { firestore } from 'firebase'
import { walkSet } from '../../src/core'

// Vue.config.productionTip = false
// Vue.config.devtools = false
export { Vue, MockFirebase, MockedReference }
export { MockFirebase, MockedReference }

export * from './mock'

Expand Down
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"version": "3.0.0",
"description": "Some awesome description",
"main": "dist/vuefire.cjs.js",
"browser": "dist/vuefire.esm-browser.js",
"unpkg": "dist/vuefire.global.js",
"jsdelivr": "dist/vuefire.global.js",
"unpkg": "dist/vuefire.global-vue-2.js",
"jsdelivr": "dist/vuefire.global-vue-2.js",
"module": "dist/vuefire.esm-bundler.js",
"types": "dist/vuefire.d.ts",
"sideEffects": false,
Expand Down Expand Up @@ -84,7 +83,8 @@
}
],
"peerDependencies": {
"vue": "^3.0.0-beta.20"
"@vue/composition-api": "^1.0.0-beta.1",
"vue": "^2.0.0 || >=3.0.0-rc.0"
},
"repository": {
"type": "git",
Expand All @@ -93,5 +93,8 @@
"bugs": {
"url": "https://github.com/posva/vuefire/issues"
},
"homepage": "https://github.com/posva/vuefire#readme"
"homepage": "https://github.com/posva/vuefire#readme",
"dependencies": {
"vue-demi": "^0.4.5"
}
}
18 changes: 9 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const outputConfigs = {
file: pkg.main,
format: `cjs`,
},
global: {
file: pkg.unpkg,
'global-vue-3': {
file: pkg.unpkg.replace('2', '3'),
format: `iife`,
},
esm: {
file: pkg.browser,
format: `es`,
'global-vue-2': {
file: pkg.unpkg,
format: `iife`,
},
}

Expand All @@ -61,7 +61,7 @@ const packageConfigs = packageFormats.map((format) =>
packageFormats.forEach((format) => {
if (format === 'cjs') {
packageConfigs.push(createProductionConfig(format))
} else if (format === 'global') {
} else if (format.startsWith('global')) {
packageConfigs.push(createMinifiedConfig(format))
}
})
Expand All @@ -77,10 +77,10 @@ function createConfig(format, output, plugins = []) {
output.sourcemap = !!process.env.SOURCE_MAP
output.banner = banner
output.externalLiveBindings = false
output.globals = { vue: 'Vue' }
output.globals = { 'vue-demi': 'VueDemi' }

const isProductionBuild = /\.prod\.js$/.test(output.file)
const isGlobalBuild = format === 'global'
const isGlobalBuild = format.startsWith('global')
const isRawESMBuild = format === 'esm'
const isNodeBuild = format === 'cjs'
const isBundlerESMBuild = /esm-bundler/.test(format)
Expand All @@ -107,7 +107,7 @@ function createConfig(format, output, plugins = []) {
// during a single build.
hasTSChecked = true

const external = ['vue']
const external = ['vue-demi']

const nodePlugins = [resolve(), commonjs()]

Expand Down
2 changes: 1 addition & 1 deletion src/firestore/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSnapshot, extractRefs, FirestoreSerializer } from './utils'
import { walkGet, callOnceWithArg, OperationsType } from '../shared'
import { firestore } from 'firebase'
import { ref, Ref, unref } from 'vue'
import { ref, Ref, unref } from 'vue-demi'

export interface FirestoreOptions {
maxRefDepth?: number
Expand Down
2 changes: 1 addition & 1 deletion src/rtdb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
RTDBSerializer,
} from './utils'
import { OperationsType, ResetOption } from '../shared'
import { ref, Ref, unref } from 'vue'
import { ref, Ref, unref } from 'vue-demi'

export interface RTDBOptions {
reset?: ResetOption
Expand Down
2 changes: 1 addition & 1 deletion src/vuefire/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ref,
Ref,
toRef,
} from 'vue'
} from 'vue-demi'

export const ops: OperationsType = {
set: (target, key, value) => walkSet(target, key, value),
Expand Down
2 changes: 1 addition & 1 deletion src/vuefire/rtdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
toRef,
getCurrentInstance,
onBeforeUnmount,
} from 'vue'
} from 'vue-demi'

/**
* Returns the original reference of a Firebase reference or query across SDK versions.
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8910,6 +8910,11 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==

vue-demi@^0.4.5:
version "0.4.5"
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.4.5.tgz#ea422a4468cb6321a746826a368a770607f87791"
integrity sha512-51xf1B6hV2PfjnzYHO/yUForFCRQ49KS8ngQb5T6l1HDEmfghTFtsxtRa5tbx4eqQsH76ll/0gIxuf1gei0ubw==

vue@^3.0.0-rc.5:
version "3.0.3"
resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.3.tgz#ad94a475e6ebbf3904673b6a0ae46e47b957bd72"
Expand Down

0 comments on commit 6571605

Please sign in to comment.