From: Daniel Roe Date: Mon, 8 Nov 2021 10:18:45 +0000 (+0000) Subject: refactor: remove kit dependency (#776) X-Git-Tag: @pinia/nuxt@0.1.3~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d4084a3eeb08c2831a8885e5df4e0d817bbe401;p=thirdparty%2Fvuejs%2Fpinia.git refactor: remove kit dependency (#776) --- diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index dfcea717..59a9d5da 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -44,7 +44,6 @@ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . -l @pinia/nuxt -r 1" }, "dependencies": { - "@nuxt/kit": "latest", "vue-demi": "*" }, "devDependencies": { diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index 246d9807..61d211bc 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -1,10 +1,9 @@ /** * @module @pinia/nuxt */ -import { addPlugin, defineNuxtModule } from '@nuxt/kit' import { isVue2 } from 'vue-demi' import type { Pinia } from 'pinia' -import type { Context } from '@nuxt/types' +import type { Context, Module } from '@nuxt/types' export interface PiniaNuxtOptions { /** @@ -16,32 +15,34 @@ export interface PiniaNuxtOptions { disableVuex?: boolean } -const module = defineNuxtModule({ - name: 'pinia', - configKey: 'pinia', - defaults: { - disableVuex: true, - }, - setup(options, nuxt) { - // Disable default Vuex store (options.features only exists in Nuxt v2.10+) - if (nuxt.options.features && options.disableVuex) { - nuxt.options.features.store = false - } +const DEFAULTS = { + disableVuex: true, +} + +export default function (_options) { + const nuxt = this.nuxt + const options = { + ...DEFAULTS, + ...(_options || {}), + ...(nuxt.options.pinia || {}), + } - // make sure we use the mjs for pinia so node doesn't complain about using a module js with an extension that is js - // but doesn't have the type: module in its packages.json file - nuxt.options.alias.pinia = 'pinia/dist/pinia.mjs' + // Disable default Vuex store (options.features only exists in Nuxt v2.10+) + if (nuxt.options.features && options.disableVuex) { + nuxt.options.features.store = false + } - addPlugin({ src: require.resolve('./plugin.mjs') }) + // make sure we use the mjs for pinia so node doesn't complain about using a module js with an extension that is js + // but doesn't have the type: module in its packages.json file + nuxt.options.alias.pinia = 'pinia/dist/pinia.mjs' - // transpile pinia for nuxt 2 and nuxt bridge - if (isVue2 && !nuxt.options.build.transpile.includes('pinia')) { - nuxt.options.build.transpile.push('pinia') - } - }, -}) + this.addPlugin({ src: require.resolve('./plugin.mjs') }) -export default module + // transpile pinia for nuxt 2 and nuxt bridge + if (isVue2 && !nuxt.options.build.transpile.includes('pinia')) { + nuxt.options.build.transpile.push('pinia') + } +} declare module '@nuxt/types' { export interface Context { diff --git a/yarn.lock b/yarn.lock index 2c155fe0..e71c527c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1433,39 +1433,6 @@ node-gyp "^7.1.0" read-package-json-fast "^2.0.1" -"@nuxt/kit-edge@latest": - version "3.0.0-27265876.3cd4494" - resolved "https://registry.yarnpkg.com/@nuxt/kit-edge/-/kit-edge-3.0.0-27265876.3cd4494.tgz#3375d07f032a41ae6b58dc3725fae15ef5a76234" - integrity sha512-69oWKZiHPajONbxf4lPJdMp3Y6MlGmArVn283mlevv7jblrhQmEDDQrcfW7BIvuJ2athhfk7g8L9Ase0I1qIKg== - dependencies: - consola "^2.15.3" - create-require "^1.1.1" - defu "^5.0.0" - dotenv "^10.0.0" - globby "^11.0.4" - hash-sum "^2.0.0" - hookable "^5.0.0" - jiti "^1.12.9" - lodash.template "^4.5.0" - mlly "^0.3.12" - pathe "^0.2.0" - pkg-types "^0.3.1" - rc9 "^1.2.0" - scule "^0.2.1" - semver "^7.3.5" - std-env "^3.0.0" - ufo "^0.7.9" - unctx "^1.0.2" - untyped "^0.2.11" - -"@nuxt/kit@latest": - version "0.7.0-edge" - resolved "https://registry.yarnpkg.com/@nuxt/kit/-/kit-0.7.0-edge.tgz#37da0dda70b76f9df054708ea3c066d60689f811" - integrity sha512-3+azijGDlERcmhK/Gp97cn8+I++/pn/AmYcj7ceRF++6T86ohckAY0ip/+y4dLlWJ0AGnwB6x4gybG03ltEPew== - dependencies: - "@nuxt/kit-edge" latest - jiti "^1.12.9" - "@nuxt/types@^2.15.8": version "2.15.8" resolved "https://registry.yarnpkg.com/@nuxt/types/-/types-2.15.8.tgz#1249de448f68169fe17e9379ee7b5caa0eb336b0" @@ -3215,11 +3182,6 @@ cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: path-type "^4.0.0" yaml "^1.10.0" -create-require@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -3350,11 +3312,6 @@ define-properties@^1.1.3: dependencies: object-keys "^1.0.12" -defu@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/defu/-/defu-2.0.4.tgz#09659a6e87a8fd7178be13bd43e9357ebf6d1c46" - integrity sha512-G9pEH1UUMxShy6syWk01VQSRVs3CDWtlxtZu7A+NyqjxaCA4gSlWAKDBx6QiUEKezqS8+DUlXLI14Fp05Hmpwg== - defu@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/defu/-/defu-5.0.0.tgz#5768f0d402a555bfc4c267246b20f82ce8b5a10b" @@ -3380,11 +3337,6 @@ deprecation@^2.0.0, deprecation@^2.3.1: resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== -destr@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/destr/-/destr-1.1.0.tgz#2da6add6ba71e04fd0abfb1e642d4f6763235095" - integrity sha512-Ev/sqS5AzzDwlpor/5wFCDu0dYMQu/0x2D6XfAsQ0E7uQmamIgYJ6Dppo2T2EOFVkeVYWjc+PCLKaqZZ57qmLg== - detect-indent@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d" @@ -3441,11 +3393,6 @@ dot-prop@^6.0.1: dependencies: is-obj "^2.0.0" -dotenv@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" - integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q== - duplexer@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" @@ -3872,11 +3819,6 @@ find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" -flat@^5.0.0: - version "5.0.2" - resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" - integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== - forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -4153,7 +4095,7 @@ globby@10.0.0: merge2 "^1.2.3" slash "^3.0.0" -globby@^11.0.2, globby@^11.0.3, globby@^11.0.4: +globby@^11.0.2, globby@^11.0.3: version "11.0.4" resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg== @@ -4251,16 +4193,6 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -hash-sum@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/hash-sum/-/hash-sum-2.0.0.tgz#81d01bb5de8ea4a214ad5d6ead1b523460b0b45a" - integrity sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg== - -hookable@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/hookable/-/hookable-5.0.0.tgz#bac6f1d4b56e3f590f21cfe3f813731372c0c69f" - integrity sha512-IqoJ8oXCNTUtNfqwbUQvLd+6ebVXk5qqGpSMOe4BS514vd4bEEH+hd9lva48mbbbe9q4eFKmsOViTZkr7ludHg== - hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" @@ -5829,7 +5761,7 @@ mkdist@^0.3.3, mkdist@^0.3.5: mri "^1.2.0" pathe "^0.2.0" -mlly@^0.3.0, mlly@^0.3.12, mlly@^0.3.6: +mlly@^0.3.0: version "0.3.12" resolved "https://registry.yarnpkg.com/mlly/-/mlly-0.3.12.tgz#9928d517622558ea6ce3d5544df1a4f7c6687811" integrity sha512-+5DdpxP48PpfV/FcP4j/8TREPycnROCg0hX1nmD6aoZ2lD4FpZI4sxWG6l6YpUktXi/vckj8NaAl3DVQSkIn3w== @@ -6489,15 +6421,6 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -pkg-types@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/pkg-types/-/pkg-types-0.3.1.tgz#d7a8b69efb8777a05afc5aabfc259a29a5d6d159" - integrity sha512-BjECNgz/tsyqg0/T4Z/U7WbFQXUT24nfkxPbALcrk/uHVeZf9MrGG4tfvYtu+jsrHCFMseLQ6woQddDEBATw3A== - dependencies: - jsonc-parser "^3.0.0" - mlly "^0.3.6" - pathe "^0.2.0" - please-upgrade-node@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942" @@ -6659,15 +6582,6 @@ randombytes@^2.1.0: dependencies: safe-buffer "^5.1.0" -rc9@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/rc9/-/rc9-1.2.0.tgz#ef098181fdde714efc4c426383d6e46c14b1254a" - integrity sha512-/jknmhG0USFAx5uoKkAKhtG40sONds9RWhFHrP1UzJ3OvVfqFWOypSUpmsQD0fFwAV7YtzHhsn3QNasfAoxgcQ== - dependencies: - defu "^2.0.4" - destr "^1.0.0" - flat "^5.0.0" - react-is@^17.0.1: version "17.0.2" resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" @@ -7382,11 +7296,6 @@ stack-utils@^2.0.3: dependencies: escape-string-regexp "^2.0.0" -std-env@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/std-env/-/std-env-3.0.0.tgz#8dbd16bd2aadc18992072e2f5839e897f4ee2733" - integrity sha512-GoFEqAGzhaexp/T01rIiLOK9LHa6HmVwEUyeU4cwdSnOhfxpw9IMeAFi44SHWbCErEs29qEh7vAOUbtUmoycjA== - strict-uri-encode@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" @@ -7868,11 +7777,6 @@ typescript@^4.3.5, typescript@^4.4.4, typescript@~4.4.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== -ufo@^0.7.9: - version "0.7.9" - resolved "https://registry.yarnpkg.com/ufo/-/ufo-0.7.9.tgz#0268e3734b413c9ed6f3510201f42372821b875c" - integrity sha512-6t9LrLk3FhqTS+GW3IqlITtfRB5JAVr5MMNjpBECfK827W+Vh5Ilw/LhTcHWrt6b3hkeBvcbjx4Ti7QVFzmcww== - uglify-js@^3.1.4: version "3.14.3" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.14.3.tgz#c0f25dfea1e8e5323eccf59610be08b6043c15cf" @@ -7928,11 +7832,6 @@ unbuild@^0.5.11: typescript "^4.4.4" untyped "^0.2.9" -unctx@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/unctx/-/unctx-1.0.2.tgz#d8d9c83a0965aa277f61058c94548fcee6861e48" - integrity sha512-qxRfnQZWJqkg180JeOCJEvtjj5/7wnWVqkNHln8muY5/z8kMWBFqikFBPwIPCQrZJ+jtaSWkVHJkuHUAXls6zw== - unique-filename@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230" @@ -7962,7 +7861,7 @@ universalify@^2.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== -untyped@^0.2.11, untyped@^0.2.9: +untyped@^0.2.9: version "0.2.11" resolved "https://registry.yarnpkg.com/untyped/-/untyped-0.2.11.tgz#a956977e82ad1186232995bc4ba4b68ae7d20b26" integrity sha512-KVNcu9jB+mlnQJiunAzmqpnnn9R+yniT+AkOk9ZgCIsThwh0nlP6wO+O7mJjHM7Y2yplEu3v6NNtRvb82+uGxw==