Skip to content

Commit a046bde

Browse files
committed
refactor: wip remove vue-demi
1 parent 7279955 commit a046bde

22 files changed

+88
-205
lines changed

packages/docs/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig, Plugin } from 'vite'
1+
import { defineConfig, type Plugin } from 'vite'
22
import _fs from 'fs'
33
import path from 'path'
44
// import TypeDocPlugin from './vite-typedoc-plugin'
@@ -24,7 +24,7 @@ export default defineConfig({
2424
__BROWSER__: 'true',
2525
},
2626
optimizeDeps: {
27-
exclude: ['vue-demi', '@vueuse/shared', '@vueuse/core', 'pinia'],
27+
exclude: ['@vueuse/shared', '@vueuse/core', 'pinia'],
2828
},
2929
})
3030

packages/nuxt/src/runtime/plugin.vue2.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

packages/pinia/__tests__/storeToRefs.spec.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { describe, beforeEach, it, expect, vi } from 'vitest'
22
import { computed, reactive, ref, ToRefs } from 'vue'
33
import { createPinia, defineStore, setActivePinia, storeToRefs } from '../src'
4-
import { set } from 'vue-demi'
54

65
describe('storeToRefs', () => {
76
beforeEach(() => {
@@ -181,11 +180,10 @@ describe('storeToRefs', () => {
181180
const { double } = storeToRefs(store)
182181

183182
// Assuming HMR operation
184-
set(
185-
store,
186-
'double',
183+
// @ts-expect-error: hmr
184+
store.double =
185+
//
187186
computed(() => 1)
188-
)
189187

190188
expect(double.value).toEqual(1)
191189
})

packages/pinia/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@
7373
"@vue/test-utils": "^2.4.6"
7474
},
7575
"dependencies": {
76-
"@vue/devtools-api": "^6.6.3",
77-
"vue-demi": "^0.14.10"
76+
"@vue/devtools-api": "^6.6.3"
7877
},
7978
"peerDependencies": {
8079
"typescript": ">=4.4.4",

packages/pinia/src/createPinia.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Pinia, PiniaPlugin, setActivePinia, piniaSymbol } from './rootStore'
2-
import { ref, App, markRaw, effectScope, isVue2, Ref } from 'vue-demi'
2+
import { ref, App, markRaw, effectScope, Ref } from 'vue'
33
import { registerPiniaDevtools, devtoolsPlugin } from './devtools'
44
import { IS_CLIENT } from './env'
55
import { StateTree, StoreGeneric } from './types'
@@ -24,21 +24,19 @@ export function createPinia(): Pinia {
2424
// this allows calling useStore() outside of a component setup after
2525
// installing pinia's plugin
2626
setActivePinia(pinia)
27-
if (!isVue2) {
28-
pinia._a = app
29-
app.provide(piniaSymbol, pinia)
30-
app.config.globalProperties.$pinia = pinia
31-
/* istanbul ignore else */
32-
if (__USE_DEVTOOLS__ && IS_CLIENT) {
33-
registerPiniaDevtools(app, pinia)
34-
}
35-
toBeInstalled.forEach((plugin) => _p.push(plugin))
36-
toBeInstalled = []
27+
pinia._a = app
28+
app.provide(piniaSymbol, pinia)
29+
app.config.globalProperties.$pinia = pinia
30+
/* istanbul ignore else */
31+
if (__USE_DEVTOOLS__ && IS_CLIENT) {
32+
registerPiniaDevtools(app, pinia)
3733
}
34+
toBeInstalled.forEach((plugin) => _p.push(plugin))
35+
toBeInstalled = []
3836
},
3937

4038
use(plugin) {
41-
if (!this._a && !isVue2) {
39+
if (!this._a) {
4240
toBeInstalled.push(plugin)
4341
} else {
4442
_p.push(plugin)

packages/pinia/src/devtools/formatting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
CustomInspectorState,
55
} from '@vue/devtools-api'
66
import { MutationType, StoreGeneric } from '../types'
7-
import { DebuggerEvent } from 'vue-demi'
7+
import { DebuggerEvent } from 'vue'
88
import { Pinia } from '../rootStore'
99
import { isPinia } from './utils'
1010

packages/pinia/src/devtools/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
TimelineEvent,
44
App as DevtoolsApp,
55
} from '@vue/devtools-api'
6-
import { ComponentPublicInstance, markRaw, toRaw, unref, watch } from 'vue-demi'
6+
import { ComponentPublicInstance, markRaw, toRaw, unref, watch } from 'vue'
77
import { Pinia, PiniaPluginContext } from '../rootStore'
88
import {
99
_GettersTree,

packages/pinia/src/hmr.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isRef, isReactive, isVue2, set } from 'vue-demi'
1+
import { isRef, isReactive } from 'vue'
22
import { Pinia } from './rootStore'
33
import {
44
isPlainObject,
@@ -53,11 +53,7 @@ export function patchObject(
5353
} else {
5454
// objects are either a bit more complex (e.g. refs) or primitives, so we
5555
// just set the whole thing
56-
if (isVue2) {
57-
set(newState, key, subPatch)
58-
} else {
59-
newState[key] = subPatch
60-
}
56+
newState[key] = subPatch
6157
}
6258
}
6359

packages/pinia/src/mapHelpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ComponentPublicInstance, ComputedRef, UnwrapRef } from 'vue-demi'
1+
import type { ComponentPublicInstance, ComputedRef, UnwrapRef } from 'vue'
22
import type {
33
_GettersTree,
44
_StoreWithGetters_Writable,

packages/pinia/src/rootStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
hasInjectionContext,
66
InjectionKey,
77
Ref,
8-
} from 'vue-demi'
8+
} from 'vue'
99
import {
1010
StateTree,
1111
PiniaCustomProperties,

0 commit comments

Comments
 (0)