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

Commit 6571605

Browse files
committed
feat: make it work with Vue 2
1 parent e630455 commit 6571605

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

__tests__/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import Vue, { nextTick } from 'vue'
1+
import { nextTick } from 'vue-demi'
22
import { MockFirebase, MockedReference } from 'firebase-mock'
33
import { firestore } from 'firebase'
44
import { walkSet } from '../../src/core'
55

66
// Vue.config.productionTip = false
77
// Vue.config.devtools = false
8-
export { Vue, MockFirebase, MockedReference }
8+
export { MockFirebase, MockedReference }
99

1010
export * from './mock'
1111

package.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"version": "3.0.0",
44
"description": "Some awesome description",
55
"main": "dist/vuefire.cjs.js",
6-
"browser": "dist/vuefire.esm-browser.js",
7-
"unpkg": "dist/vuefire.global.js",
8-
"jsdelivr": "dist/vuefire.global.js",
6+
"unpkg": "dist/vuefire.global-vue-2.js",
7+
"jsdelivr": "dist/vuefire.global-vue-2.js",
98
"module": "dist/vuefire.esm-bundler.js",
109
"types": "dist/vuefire.d.ts",
1110
"sideEffects": false,
@@ -84,7 +83,8 @@
8483
}
8584
],
8685
"peerDependencies": {
87-
"vue": "^3.0.0-beta.20"
86+
"@vue/composition-api": "^1.0.0-beta.1",
87+
"vue": "^2.0.0 || >=3.0.0-rc.0"
8888
},
8989
"repository": {
9090
"type": "git",
@@ -93,5 +93,8 @@
9393
"bugs": {
9494
"url": "https://github.com/posva/vuefire/issues"
9595
},
96-
"homepage": "https://github.com/posva/vuefire#readme"
96+
"homepage": "https://github.com/posva/vuefire#readme",
97+
"dependencies": {
98+
"vue-demi": "^0.4.5"
99+
}
97100
}

rollup.config.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ const outputConfigs = {
4141
file: pkg.main,
4242
format: `cjs`,
4343
},
44-
global: {
45-
file: pkg.unpkg,
44+
'global-vue-3': {
45+
file: pkg.unpkg.replace('2', '3'),
4646
format: `iife`,
4747
},
48-
esm: {
49-
file: pkg.browser,
50-
format: `es`,
48+
'global-vue-2': {
49+
file: pkg.unpkg,
50+
format: `iife`,
5151
},
5252
}
5353

@@ -61,7 +61,7 @@ const packageConfigs = packageFormats.map((format) =>
6161
packageFormats.forEach((format) => {
6262
if (format === 'cjs') {
6363
packageConfigs.push(createProductionConfig(format))
64-
} else if (format === 'global') {
64+
} else if (format.startsWith('global')) {
6565
packageConfigs.push(createMinifiedConfig(format))
6666
}
6767
})
@@ -77,10 +77,10 @@ function createConfig(format, output, plugins = []) {
7777
output.sourcemap = !!process.env.SOURCE_MAP
7878
output.banner = banner
7979
output.externalLiveBindings = false
80-
output.globals = { vue: 'Vue' }
80+
output.globals = { 'vue-demi': 'VueDemi' }
8181

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

110-
const external = ['vue']
110+
const external = ['vue-demi']
111111

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

src/firestore/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createSnapshot, extractRefs, FirestoreSerializer } from './utils'
22
import { walkGet, callOnceWithArg, OperationsType } from '../shared'
33
import { firestore } from 'firebase'
4-
import { ref, Ref, unref } from 'vue'
4+
import { ref, Ref, unref } from 'vue-demi'
55

66
export interface FirestoreOptions {
77
maxRefDepth?: number

src/rtdb/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
RTDBSerializer,
66
} from './utils'
77
import { OperationsType, ResetOption } from '../shared'
8-
import { ref, Ref, unref } from 'vue'
8+
import { ref, Ref, unref } from 'vue-demi'
99

1010
export interface RTDBOptions {
1111
reset?: ResetOption

src/vuefire/firestore.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
ref,
1717
Ref,
1818
toRef,
19-
} from 'vue'
19+
} from 'vue-demi'
2020

2121
export const ops: OperationsType = {
2222
set: (target, key, value) => walkSet(target, key, value),

src/vuefire/rtdb.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
toRef,
1515
getCurrentInstance,
1616
onBeforeUnmount,
17-
} from 'vue'
17+
} from 'vue-demi'
1818

1919
/**
2020
* Returns the original reference of a Firebase reference or query across SDK versions.

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -8910,6 +8910,11 @@ vm-browserify@^1.0.1:
89108910
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
89118911
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==
89128912

8913+
vue-demi@^0.4.5:
8914+
version "0.4.5"
8915+
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.4.5.tgz#ea422a4468cb6321a746826a368a770607f87791"
8916+
integrity sha512-51xf1B6hV2PfjnzYHO/yUForFCRQ49KS8ngQb5T6l1HDEmfghTFtsxtRa5tbx4eqQsH76ll/0gIxuf1gei0ubw==
8917+
89138918
vue@^3.0.0-rc.5:
89148919
version "3.0.3"
89158920
resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.3.tgz#ad94a475e6ebbf3904673b6a0ae46e47b957bd72"

0 commit comments

Comments
 (0)