fix(nuxt): broken capo.js injectHead usage (#22447)

This commit is contained in:
Harlan Wilton 2023-08-03 09:15:43 +03:00 committed by GitHub
parent 7489b7d7cc
commit ac93558aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 62 deletions

View File

@ -58,8 +58,8 @@
"@nuxt/telemetry": "^2.3.2", "@nuxt/telemetry": "^2.3.2",
"@nuxt/ui-templates": "^1.3.1", "@nuxt/ui-templates": "^1.3.1",
"@nuxt/vite-builder": "workspace:../vite", "@nuxt/vite-builder": "workspace:../vite",
"@unhead/ssr": "^1.2.1", "@unhead/ssr": "^1.2.2",
"@unhead/vue": "^1.2.1", "@unhead/vue": "^1.2.2",
"@vue/shared": "^3.3.4", "@vue/shared": "^3.3.4",
"acorn": "8.10.0", "acorn": "8.10.0",
"c12": "^1.4.2", "c12": "^1.4.2",

View File

@ -1,9 +1,9 @@
import { CapoPlugin, injectHead } from '@unhead/vue' import { CapoPlugin } from '@unhead/vue'
import { defineNuxtPlugin } from '#app/nuxt' import { defineNuxtPlugin } from '#app/nuxt'
export default defineNuxtPlugin({ export default defineNuxtPlugin({
name: 'nuxt:head:capo', name: 'nuxt:head:capo',
setup () { setup (nuxtApp) {
injectHead().use(CapoPlugin()) nuxtApp.vueApp._context.provides.usehead.use(CapoPlugin({ track: true }))
} }
}) })

View File

@ -30,7 +30,7 @@
"@types/file-loader": "5.0.1", "@types/file-loader": "5.0.1",
"@types/pug": "2.0.6", "@types/pug": "2.0.6",
"@types/sass-loader": "8.0.5", "@types/sass-loader": "8.0.5",
"@unhead/schema": "1.2.1", "@unhead/schema": "1.2.2",
"@vitejs/plugin-vue": "4.2.3", "@vitejs/plugin-vue": "4.2.3",
"@vitejs/plugin-vue-jsx": "3.0.1", "@vitejs/plugin-vue-jsx": "3.0.1",
"@vue/compiler-core": "3.3.4", "@vue/compiler-core": "3.3.4",

View File

@ -210,7 +210,9 @@ export default defineUntypedSchema({
watcher: 'chokidar-granular', watcher: 'chokidar-granular',
/** /**
* Add the CAPO head plugin in order to render tags in of the head in a more performant way. * Add the capo.js head plugin in order to render tags in of the head in a more performant way.
*
* @see https://rviscomi.github.io/capo.js/user/rules/
*/ */
headCapoPlugin: false headCapoPlugin: false
} }

View File

@ -359,11 +359,11 @@ importers:
specifier: ^14.18.0 || >=16.10.0 specifier: ^14.18.0 || >=16.10.0
version: 18.17.1 version: 18.17.1
'@unhead/ssr': '@unhead/ssr':
specifier: ^1.2.1 specifier: ^1.2.2
version: 1.2.1 version: 1.2.2
'@unhead/vue': '@unhead/vue':
specifier: ^1.2.1 specifier: ^1.2.2
version: 1.2.1(vue@3.3.4) version: 1.2.2(vue@3.3.4)
'@vue/shared': '@vue/shared':
specifier: ^3.3.4 specifier: ^3.3.4
version: 3.3.4 version: 3.3.4
@ -568,8 +568,8 @@ importers:
specifier: 8.0.5 specifier: 8.0.5
version: 8.0.5 version: 8.0.5
'@unhead/schema': '@unhead/schema':
specifier: 1.2.1 specifier: 1.2.2
version: 1.2.1 version: 1.2.2
'@vitejs/plugin-vue': '@vitejs/plugin-vue':
specifier: 4.2.3 specifier: 4.2.3
version: 4.2.3(vite@4.4.7)(vue@3.3.4) version: 4.2.3(vite@4.4.7)(vue@3.3.4)
@ -988,7 +988,7 @@ importers:
version: 1.1.1 version: 1.1.1
vitest: vitest:
specifier: latest specifier: latest
version: 0.34.0(happy-dom@10.5.2) version: 0.34.1(happy-dom@10.5.2)
vue: vue:
specifier: 3.3.4 specifier: 3.3.4
version: 3.3.4 version: 3.3.4
@ -2789,41 +2789,41 @@ packages:
eslint-visitor-keys: 3.4.2 eslint-visitor-keys: 3.4.2
dev: true dev: true
/@unhead/dom@1.2.1: /@unhead/dom@1.2.2:
resolution: {integrity: sha512-Kjo6bJpo2RFUlhPq/fGQbUpTdfNSwbwg3vjMmqxCPcTWg87sv+a3kNnIP3c/CV0Sc34OsMY/0Melx+0BAu937g==} resolution: {integrity: sha512-ohganmg4i1Dd4wwQ2A9oLWEkJNpJRoERJNmFgzmScw9Vi3zMqoS4gPIofT20zUR5rhyyAsFojuDPojJ5vKcmqw==}
dependencies: dependencies:
'@unhead/schema': 1.2.1 '@unhead/schema': 1.2.2
'@unhead/shared': 1.2.1 '@unhead/shared': 1.2.2
dev: false dev: false
/@unhead/schema@1.2.1: /@unhead/schema@1.2.2:
resolution: {integrity: sha512-b0NVAXqFEP2K5Tu3Zkv+MUGnwDMjetEEa8Dw4i0z4rrO3J5Kg1TCp4C+wWCx2d8M6US6yI1TE636K9ll8WophQ==} resolution: {integrity: sha512-cGtNvadL76eGl7QxGjWHZxFqLv9a2VrmRpeEb1d7sm0cvnN0bWngdXDTdUyXzn7RVv/Um+/yae6eiT6A+pyQOw==}
dependencies: dependencies:
hookable: 5.5.3 hookable: 5.5.3
zhead: 2.0.10 zhead: 2.0.10
/@unhead/shared@1.2.1: /@unhead/shared@1.2.2:
resolution: {integrity: sha512-tZa/vm2LKoaduPIaol/lQQSX1eY0YCqoktHDO+Vyc9hhoT/oqP2L9LbUjgunQysxbAPKLsgqS0rrXGP+j1fShw==} resolution: {integrity: sha512-bWRjRyVzFsunih9GbHctvS8Aenj6KBe5ycql1JE4LawBL/NRYvCYUCPpdK5poVOqjYr0yDAf9m4JGaM2HwpVLw==}
dependencies: dependencies:
'@unhead/schema': 1.2.1 '@unhead/schema': 1.2.2
dev: false dev: false
/@unhead/ssr@1.2.1: /@unhead/ssr@1.2.2:
resolution: {integrity: sha512-Bho966xG896mfq/8QxN8kkWJhju+pwTZLc6Z3ixKUnYshXAYHocxRpbRJYGZaqnIDAFeIPX9pkhuXfQJ6NuAVA==} resolution: {integrity: sha512-mpWSNNbrQFJZolAfdVInPPiSGUva08bK9UbNV1zgDScUz+p+FnRg4cj77X+PpVeJ0+KPgjXfOsI8VQKYt+buYA==}
dependencies: dependencies:
'@unhead/schema': 1.2.1 '@unhead/schema': 1.2.2
'@unhead/shared': 1.2.1 '@unhead/shared': 1.2.2
dev: false dev: false
/@unhead/vue@1.2.1(vue@3.3.4): /@unhead/vue@1.2.2(vue@3.3.4):
resolution: {integrity: sha512-UwL4SSn2Mwe6iNHg/KryDVGGPMp3PR56rl6l5j5+W3oii1E3ZgJk7sNUCcKrOkfITirU2IAkmdfiDfQdc0KTow==} resolution: {integrity: sha512-AxOmY5JPn4fS34ovaivPnqg2my+InIkZDNSxCKfRkmbBtstFre/Fyf0d92Qfx0u8PJiSRPOjthEHx5vKDgTEJQ==}
peerDependencies: peerDependencies:
vue: '>=2.7 || >=3' vue: '>=2.7 || >=3'
dependencies: dependencies:
'@unhead/schema': 1.2.1 '@unhead/schema': 1.2.2
'@unhead/shared': 1.2.1 '@unhead/shared': 1.2.2
hookable: 5.5.3 hookable: 5.5.3
unhead: 1.2.1 unhead: 1.2.2
vue: 3.3.4 vue: 3.3.4
dev: false dev: false
@ -2880,11 +2880,11 @@ packages:
chai: 4.3.7 chai: 4.3.7
dev: true dev: true
/@vitest/expect@0.34.0: /@vitest/expect@0.34.1:
resolution: {integrity: sha512-d1ZU0XomWFAFyYIc6uNuY0N8NJIWESyO/6ZmwLvlHZw0GevH4AEEpq178KjXIvSCrbHN0GnzYzitd0yjfy7+Ow==} resolution: {integrity: sha512-q2CD8+XIsQ+tHwypnoCk8Mnv5e6afLFvinVGCq3/BOT4kQdVQmY6rRfyKkwcg635lbliLPqbunXZr+L1ssUWiQ==}
dependencies: dependencies:
'@vitest/spy': 0.34.0 '@vitest/spy': 0.34.1
'@vitest/utils': 0.34.0 '@vitest/utils': 0.34.1
chai: 4.3.7 chai: 4.3.7
dev: true dev: true
@ -2896,10 +2896,10 @@ packages:
pathe: 1.1.1 pathe: 1.1.1
dev: true dev: true
/@vitest/runner@0.34.0: /@vitest/runner@0.34.1:
resolution: {integrity: sha512-xaqM+oArJothtYXzy/dwu/iHe93Khq5QkvnYbzTxiLA0enD2peft1cask3yE6cJpwMkr7C2D1uMJwnTt4mquDw==} resolution: {integrity: sha512-YfQMpYzDsYB7yqgmlxZ06NI4LurHWfrH7Wy3Pvf/z/vwUSgq1zLAb1lWcItCzQG+NVox+VvzlKQrYEXb47645g==}
dependencies: dependencies:
'@vitest/utils': 0.34.0 '@vitest/utils': 0.34.1
p-limit: 4.0.0 p-limit: 4.0.0
pathe: 1.1.1 pathe: 1.1.1
dev: true dev: true
@ -2912,8 +2912,8 @@ packages:
pretty-format: 29.6.2 pretty-format: 29.6.2
dev: true dev: true
/@vitest/snapshot@0.34.0: /@vitest/snapshot@0.34.1:
resolution: {integrity: sha512-eGN5XBZHYOghxCOQbf8dcn6/3g7IW77GOOOC/mNFYwRXsPeoQgcgWnhj+6wgJ04pVv25wpxWL9jUkzaQ7LoFtg==} resolution: {integrity: sha512-0O9LfLU0114OqdF8lENlrLsnn024Tb1CsS9UwG0YMWY2oGTQfPtkW+B/7ieyv0X9R2Oijhi3caB1xgGgEgclSQ==}
dependencies: dependencies:
magic-string: 0.30.2 magic-string: 0.30.2
pathe: 1.1.1 pathe: 1.1.1
@ -2926,8 +2926,8 @@ packages:
tinyspy: 2.1.1 tinyspy: 2.1.1
dev: true dev: true
/@vitest/spy@0.34.0: /@vitest/spy@0.34.1:
resolution: {integrity: sha512-0SZaWrQvL9ZiF/uJvyWSvsKjfuMvD1M6dE5BbE4Dmt8Vh3k4htwCV8g3ce8YOYmJSxkbh6TNOpippD6NVsxW6w==} resolution: {integrity: sha512-UT4WcI3EAPUNO8n6y9QoEqynGGEPmmRxC+cLzneFFXpmacivjHZsNbiKD88KUScv5DCHVDgdBsLD7O7s1enFcQ==}
dependencies: dependencies:
tinyspy: 2.1.1 tinyspy: 2.1.1
dev: true dev: true
@ -2955,8 +2955,8 @@ packages:
pretty-format: 29.6.2 pretty-format: 29.6.2
dev: true dev: true
/@vitest/utils@0.34.0: /@vitest/utils@0.34.1:
resolution: {integrity: sha512-IktrDLhBKf3dEUUxH+lcHiPnaw952+GdGvoxg99liMscgP6IePf6LuMY7B9dEIHkFunB1R8VMR/wmI/4UGg1aw==} resolution: {integrity: sha512-/ql9dsFi4iuEbiNcjNHQWXBum7aL8pyhxvfnD9gNtbjR9fUKAjxhj4AA3yfLXg6gJpMGGecvtF8Au2G9y3q47Q==}
dependencies: dependencies:
diff-sequences: 29.4.3 diff-sequences: 29.4.3
loupe: 2.3.6 loupe: 2.3.6
@ -8705,12 +8705,12 @@ packages:
node-fetch-native: 1.2.0 node-fetch-native: 1.2.0
pathe: 1.1.1 pathe: 1.1.1
/unhead@1.2.1: /unhead@1.2.2:
resolution: {integrity: sha512-Ox00j8my2mcTa5RtCbLexuIUAOxAQnQ2z/t8l7lHcAw4f5Ewq8vLaRYg/2Y+2WAXVC4ab+am2kYf/Sjj6VBpSw==} resolution: {integrity: sha512-9wDuiso7YWNe0BTA5NGsHR0dtqn0YrL/5+NumfuXDxxYykavc6N27pzZxTXiuvVHbod8tFicsxA6pC9WhQvzqg==}
dependencies: dependencies:
'@unhead/dom': 1.2.1 '@unhead/dom': 1.2.2
'@unhead/schema': 1.2.1 '@unhead/schema': 1.2.2
'@unhead/shared': 1.2.1 '@unhead/shared': 1.2.2
hookable: 5.5.3 hookable: 5.5.3
dev: false dev: false
@ -8903,8 +8903,8 @@ packages:
- supports-color - supports-color
- terser - terser
/vite-node@0.34.0(@types/node@18.17.1): /vite-node@0.34.1(@types/node@18.17.1):
resolution: {integrity: sha512-rGZMvpb052rjUwJA/a17xMfOibzNF7byMdRSTcN2Lw8uxX08s5EfjWW5mBkm3MSFTPctMSVtT2yC+8ShrZbT5g==} resolution: {integrity: sha512-odAZAL9xFMuAg8aWd7nSPT+hU8u2r9gU3LRm9QKjxBEF2rRdWpMuqkrkjvyVQEdNFiBctqr2Gg4uJYizm5Le6w==}
engines: {node: '>=v14.18.0'} engines: {node: '>=v14.18.0'}
hasBin: true hasBin: true
dependencies: dependencies:
@ -9112,8 +9112,8 @@ packages:
- terser - terser
dev: true dev: true
/vitest@0.34.0(happy-dom@10.5.2): /vitest@0.34.1(happy-dom@10.5.2):
resolution: {integrity: sha512-8Pnc1fVt1P6uBncdUZ++hgiJGgxIRKuz4bmS/PQziaEcUj0D1g9cGiR1MbLrcsvFTC6fgrqDhYoTAdBG356WMA==} resolution: {integrity: sha512-G1PzuBEq9A75XSU88yO5G4vPT20UovbC/2osB2KEuV/FisSIIsw7m5y2xMdB7RsAGHAfg2lPmp2qKr3KWliVlQ==}
engines: {node: '>=v14.18.0'} engines: {node: '>=v14.18.0'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@ -9146,11 +9146,11 @@ packages:
'@types/chai': 4.3.5 '@types/chai': 4.3.5
'@types/chai-subset': 1.3.3 '@types/chai-subset': 1.3.3
'@types/node': 18.17.1 '@types/node': 18.17.1
'@vitest/expect': 0.34.0 '@vitest/expect': 0.34.1
'@vitest/runner': 0.34.0 '@vitest/runner': 0.34.1
'@vitest/snapshot': 0.34.0 '@vitest/snapshot': 0.34.1
'@vitest/spy': 0.34.0 '@vitest/spy': 0.34.1
'@vitest/utils': 0.34.0 '@vitest/utils': 0.34.1
acorn: 8.10.0 acorn: 8.10.0
acorn-walk: 8.2.0 acorn-walk: 8.2.0
cac: 6.7.14 cac: 6.7.14
@ -9166,7 +9166,7 @@ packages:
tinybench: 2.5.0 tinybench: 2.5.0
tinypool: 0.7.0 tinypool: 0.7.0
vite: 4.4.7(@types/node@18.17.1) vite: 4.4.7(@types/node@18.17.1)
vite-node: 0.34.0(@types/node@18.17.1) vite-node: 0.34.1(@types/node@18.17.1)
why-is-node-running: 2.2.2 why-is-node-running: 2.2.2
transitivePeerDependencies: transitivePeerDependencies:
- less - less

View File

@ -35,7 +35,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"64.4k"') expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"64.4k"')
const modules = await analyzeSizes('node_modules/**/*', serverDir) const modules = await analyzeSizes('node_modules/**/*', serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2331k"') expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2332k"')
const packages = modules.files const packages = modules.files
.filter(m => m.endsWith('package.json')) .filter(m => m.endsWith('package.json'))

View File

@ -187,7 +187,8 @@ export default defineNuxtConfig({
componentIslands: true, componentIslands: true,
reactivityTransform: true, reactivityTransform: true,
treeshakeClientOnly: true, treeshakeClientOnly: true,
payloadExtraction: true payloadExtraction: true,
headCapoPlugin: true
}, },
appConfig: { appConfig: {
fromNuxtConfig: true, fromNuxtConfig: true,