Skip to content

Commit 1e45f33

Browse files
authored
fix: avoid npm bug when resolving optional deps (#2841)
1 parent 7f23474 commit 1e45f33

File tree

5 files changed

+6
-25
lines changed

5 files changed

+6
-25
lines changed

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,6 @@ A few notes about the project and possible questions:
111111
npm install pinia
112112
```
113113

114-
If you are using Vue <2.7, make sure to install latest `@vue/composition-api`:
115-
116-
```bash
117-
npm install pinia @vue/composition-api
118-
```
119-
120114
## Usage
121115

122116
### Install the plugin

packages/pinia/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,12 @@
7777
"vue-demi": "^0.14.10"
7878
},
7979
"peerDependencies": {
80-
"@vue/composition-api": "^1.4.0",
8180
"typescript": ">=4.4.4",
82-
"vue": "^2.6.14 || ^3.5.11"
81+
"vue": "^2.7.0 || ^3.5.11"
8382
},
8483
"peerDependenciesMeta": {
8584
"typescript": {
8685
"optional": true
87-
},
88-
"@vue/composition-api": {
89-
"optional": true
9086
}
9187
},
9288
"repository": {

packages/pinia/src/store.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ function mergeReactiveObjects<
117117
const skipHydrateSymbol = __DEV__
118118
? Symbol('pinia:skipHydration')
119119
: /* istanbul ignore next */ Symbol()
120-
const skipHydrateMap = /*#__PURE__*/ new WeakMap<any, any>()
121120

122121
/**
123122
* Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a
@@ -127,10 +126,7 @@ const skipHydrateMap = /*#__PURE__*/ new WeakMap<any, any>()
127126
* @returns obj
128127
*/
129128
export function skipHydrate<T = any>(obj: T): T {
130-
return isVue2
131-
? // in @vue/composition-api, the refs are sealed so defineProperty doesn't work...
132-
/* istanbul ignore next */ skipHydrateMap.set(obj, 1) && obj
133-
: Object.defineProperty(obj, skipHydrateSymbol, {})
129+
return Object.defineProperty(obj, skipHydrateSymbol, {})
134130
}
135131

136132
/**
@@ -140,9 +136,7 @@ export function skipHydrate<T = any>(obj: T): T {
140136
* @returns true if `obj` should be hydrated
141137
*/
142138
export function shouldHydrate(obj: any) {
143-
return isVue2
144-
? /* istanbul ignore next */ !skipHydrateMap.has(obj)
145-
: !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol)
139+
return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol)
146140
}
147141

148142
const { assign } = Object

pnpm-lock.yaml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rollup.config.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ function createConfig(buildName, output, plugins = []) {
9696
output.globals = {
9797
'vue-demi': 'VueDemi',
9898
vue: 'Vue',
99-
'@vue/composition-api': 'vueCompositionApi',
10099
}
101100

102101
const isProductionBuild = /\.prod\.[cm]?js$/.test(output.file)
@@ -127,7 +126,7 @@ function createConfig(buildName, output, plugins = []) {
127126
// during a single build.
128127
hasTSChecked = true
129128

130-
const external = ['vue-demi', 'vue', '@vue/composition-api']
129+
const external = ['vue-demi', 'vue']
131130
if (
132131
!isGlobalBuild &&
133132
// pinia.prod.cjs should not require `@vue/devtools-api` (like Vue)

0 commit comments

Comments
 (0)