Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 86ed34e

Browse files
authored
fix: add meta plugin after other modules (#481)
* enables use with `@nuxtjs/pwa`
1 parent 84a6b48 commit 86ed34e

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"@nuxt/types": "^2.15.5",
7979
"@nuxt/typescript-build": "^2.1.0",
8080
"@nuxtjs/module-test-utils": "^1.6.3",
81+
"@nuxtjs/pwa": "^3.3.5",
8182
"@release-it/conventional-changelog": "^2.0.1",
8283
"@types/fs-extra": "^9.0.11",
8384
"@types/jest": "^26.0.23",

src/module.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,13 @@ const compositionApiModule: Module<never> = function compositionApiModule() {
6565
// Plugin to allow running onGlobalSetup
6666
const globalPlugin = addResolvedTemplate.call(this, 'plugin.mjs')
6767

68+
// Allow setting head() within onGlobalSetup
69+
const metaPlugin = addResolvedTemplate.call(this, 'meta.mjs')
70+
6871
this.nuxt.hook('modules:done', () => {
72+
nuxtOptions.plugins.push(metaPlugin)
6973
nuxtOptions.plugins.unshift(globalPlugin)
7074
})
71-
72-
// TODO: remove
73-
// Allow setting head() within onGlobalSetup
74-
75-
if (
76-
!nuxtOptions.buildModules.includes('@nuxtjs/pwa') &&
77-
!nuxtOptions.modules.includes('@nuxtjs/pwa')
78-
) {
79-
nuxtOptions.plugins.push(addResolvedTemplate.call(this, 'meta.mjs'))
80-
} else if (nuxtOptions.dev) {
81-
console.warn(
82-
'useMeta is not supported in onGlobalSetup as @nuxtjs/pwa detected.\nSee https://github.com/nuxt-community/composition-api/issues/307'
83-
)
84-
}
8575
}
8676

8777
// eslint-disable-next-line

test/fixture/nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export default <NuxtConfig>{
7575
},
7676
buildModules: [
7777
'@nuxt/typescript-build',
78+
'@nuxtjs/pwa',
7879
join(rootDir, inDevelopment ? 'src' : 'dist', 'module'),
7980
],
8081
pwa: {

yarn.lock

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,21 @@
16681668
request "^2.88.2"
16691669
request-promise-native "^1.0.8"
16701670

1671+
"@nuxtjs/pwa@^3.3.5":
1672+
version "3.3.5"
1673+
resolved "https://registry.yarnpkg.com/@nuxtjs/pwa/-/pwa-3.3.5.tgz#db7c905536ebe8a464a347b6ae3215810642c044"
1674+
integrity sha512-8tTmW8DBspWxlJwTimOHTkwfkwPpL9wIcGmy75Gcmin+c9YtX2Ehxmhgt/TLFOC9XsLAqojqynw3/Agr/9OE1w==
1675+
dependencies:
1676+
clone-deep "^4.0.1"
1677+
defu "^3.2.2"
1678+
execa "^5.0.0"
1679+
fs-extra "^9.1.0"
1680+
hasha "^5.2.2"
1681+
jimp-compact "^0.16.1"
1682+
lodash.template "^4.5.0"
1683+
serve-static "^1.14.1"
1684+
workbox-cdn "^5.1.4"
1685+
16711686
"@nuxtjs/youch@^4.2.3":
16721687
version "4.2.3"
16731688
resolved "https://registry.yarnpkg.com/@nuxtjs/youch/-/youch-4.2.3.tgz#36f8b22df5a0efaa81373109851e1d857aca6bed"
@@ -6796,6 +6811,14 @@ hash.js@^1.0.0, hash.js@^1.0.3:
67966811
inherits "^2.0.3"
67976812
minimalistic-assert "^1.0.1"
67986813

6814+
hasha@^5.2.2:
6815+
version "5.2.2"
6816+
resolved "https://registry.yarnpkg.com/hasha/-/hasha-5.2.2.tgz#a48477989b3b327aea3c04f53096d816d97522a1"
6817+
integrity sha512-Hrp5vIK/xr5SkeN2onO32H0MgNZ0f17HRNH39WfL0SYUNOTZ5Lz1TJ8Pajo/87dYGEFlLMm7mIc/k/s6Bvz9HQ==
6818+
dependencies:
6819+
is-stream "^2.0.0"
6820+
type-fest "^0.8.0"
6821+
67996822
[email protected], he@^1.1.0, he@^1.1.1, he@^1.2.0:
68006823
version "1.2.0"
68016824
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
@@ -8153,6 +8176,11 @@ jest@^26.6.3:
81538176
import-local "^3.0.2"
81548177
jest-cli "^26.6.3"
81558178

8179+
jimp-compact@^0.16.1:
8180+
version "0.16.1"
8181+
resolved "https://registry.yarnpkg.com/jimp-compact/-/jimp-compact-0.16.1.tgz#9582aea06548a2c1e04dd148d7c3ab92075aefa3"
8182+
integrity sha512-dZ6Ra7u1G8c4Letq/B5EzAxj4tLFHL+cGtdpR+PVm4yzPDj+lCk+AbivWt1eOM+ikzkowtyV7qSqX6qr3t71Ww==
8183+
81568184
jiti@^1.3.0, jiti@^1.9.1, jiti@^1.9.2:
81578185
version "1.9.2"
81588186
resolved "https://registry.yarnpkg.com/jiti/-/jiti-1.9.2.tgz#2ee44830883dbb1b2e222adc053c3052d0bf3b61"
@@ -13271,7 +13299,7 @@ type-fest@^0.6.0:
1327113299
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b"
1327213300
integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==
1327313301

13274-
type-fest@^0.8.1:
13302+
type-fest@^0.8.0, type-fest@^0.8.1:
1327513303
version "0.8.1"
1327613304
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
1327713305
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==
@@ -13987,6 +14015,11 @@ wordwrap@^1.0.0:
1398714015
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
1398814016
integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=
1398914017

14018+
workbox-cdn@^5.1.4:
14019+
version "5.1.4"
14020+
resolved "https://registry.yarnpkg.com/workbox-cdn/-/workbox-cdn-5.1.4.tgz#dbd8acee70b1978be70106207590bbb76af935cf"
14021+
integrity sha512-04gM3mi8QGutokkSaA9xunVfjURnLbo9TTWyi8+pSDCEW5cD8u5GbJiliLK1vB9CShk/9OY1UDfW+XcmD+d6KQ==
14022+
1399014023
worker-farm@^1.7.0:
1399114024
version "1.7.0"
1399214025
resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.7.0.tgz#26a94c5391bbca926152002f69b84a4bf772e5a8"

0 commit comments

Comments
 (0)