Skip to content

Commit

Permalink
fix: correct deps in nuxt plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Oct 21, 2021
1 parent 2cd3c91 commit 8020f99
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
10 changes: 7 additions & 3 deletions packages/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./templates/plugin.js": "./templates/plugin.js"
"./src/templates/*": "./dist/templates/*.js"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand All @@ -38,21 +38,25 @@
"dist/*.js",
"dist/*.mjs",
"dist/*.d.ts",
"templates/*.js"
"dist/templates/*.js"
],
"scripts": {
"build": "siroc",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l @pinia/nuxt -r 1"
},
"dependencies": {
"@nuxt/kit": "npm:@nuxt/kit-edge@latest",
"upath": "^2.0.1"
"upath": "^2.0.1",
"vue-demi": "^0.11.4"
},
"devDependencies": {
"@nuxt/types": "^2.15.8",
"pinia": "^2.0.0-0",
"siroc": "^0.16.0"
},
"peerDependencies": {
"pinia": "^2.0.0-0"
},
"publishConfig": {
"access": "public"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxt/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const module = defineNuxtModule<PiniaNuxtOptions>({
// but doesn't have the type: module in its packages.json file
nuxt.options.alias.pinia = 'pinia/index.mjs'

addPlugin({ src: resolve(__dirname, '../templates/plugin.js') })
addPlugin({ src: resolve(__dirname, './templates/plugin.js') })

// transpile pinia for nuxt 2 and nuxt bridge
if (isVue2 && !nuxt.options.build.transpile.includes('pinia')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// @ts-check
import { isVue2, Vue2 } from 'vue-demi'
import { createPinia, setActivePinia, PiniaVuePlugin } from 'pinia'
import type { Plugin } from '@nuxt/types'

if (isVue2) {
Vue2.use(PiniaVuePlugin)
}

/**
* @type {import('@nuxt/types').Plugin}
*/
const PiniaNuxtPlugin = (context, inject) => {
const PiniaNuxtPlugin: Plugin = (context, inject) => {
const pinia = createPinia()
if (isVue2) {
// simulate new Vue({ pinia })
context.app.pinia = pinia
} else {
// @ts-expect-error: vue 3 only
context.vueApp.use(pinia)
}

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8241,7 +8241,7 @@ vscode-textmate@5.2.0:
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-5.2.0.tgz#01f01760a391e8222fe4f33fbccbd1ad71aed74e"
integrity sha512-Uw5ooOQxRASHgu6C7GVvUxisKXfSgW4oFlO+aa+PAkgmH89O3CXxEEzNRNtHSqtXFTl0nAC1uYj0GMSH27uwtQ==

vue-demi@*, vue-demi@latest:
vue-demi@*, vue-demi@^0.11.4, vue-demi@latest:
version "0.11.4"
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.11.4.tgz#6101992fe4724cf5634018a16e953f3052e94e2a"
integrity sha512-/3xFwzSykLW2HiiLie43a+FFgNOcokbBJ+fzvFXd0r2T8MYohqvphUyDQ8lbAwzQ3Dlcrb1c9ykifGkhSIAk6A==
Expand Down

0 comments on commit 8020f99

Please sign in to comment.