From: Eduardo San Martin Morote Date: Thu, 21 Oct 2021 09:44:34 +0000 (+0200) Subject: fix: correct deps in nuxt plugin X-Git-Tag: @pinia/nuxt@0.0.9~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8020f996e2b3c32685c88d0652b23a86bdcba507;p=thirdparty%2Fvuejs%2Fpinia.git fix: correct deps in nuxt plugin --- diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 99677224..942d4b8d 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -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", @@ -38,7 +38,7 @@ "dist/*.js", "dist/*.mjs", "dist/*.d.ts", - "templates/*.js" + "dist/templates/*.js" ], "scripts": { "build": "siroc", @@ -46,13 +46,17 @@ }, "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" } diff --git a/packages/nuxt/src/index.ts b/packages/nuxt/src/index.ts index 28630de3..e68dc44e 100644 --- a/packages/nuxt/src/index.ts +++ b/packages/nuxt/src/index.ts @@ -33,7 +33,7 @@ const module = defineNuxtModule({ // 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')) { diff --git a/packages/nuxt/templates/plugin.js b/packages/nuxt/src/templates/plugin.ts similarity index 90% rename from packages/nuxt/templates/plugin.js rename to packages/nuxt/src/templates/plugin.ts index 59202819..78b17dc5 100644 --- a/packages/nuxt/templates/plugin.js +++ b/packages/nuxt/src/templates/plugin.ts @@ -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) } diff --git a/yarn.lock b/yarn.lock index e65444ce..4523cb81 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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==