Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(nuxt): experimental support of capo.js head tag order #22431

Merged
merged 4 commits into from Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/nuxt/package.json
Expand Up @@ -58,8 +58,8 @@
"@nuxt/telemetry": "^2.3.2",
"@nuxt/ui-templates": "^1.3.1",
"@nuxt/vite-builder": "workspace:../vite",
"@unhead/ssr": "^1.1.35",
"@unhead/vue": "^1.1.35",
"@unhead/ssr": "^1.2.1",
"@unhead/vue": "^1.2.1",
"@vue/shared": "^3.3.4",
"acorn": "8.10.0",
"c12": "^1.4.2",
Expand Down
4 changes: 4 additions & 0 deletions packages/nuxt/src/head/module.ts
Expand Up @@ -54,6 +54,10 @@ export default defineNuxtModule({
addPlugin({ src: resolve(runtimeDir, 'plugins/vueuse-head-polyfill') })
}

if (nuxt.options.experimental.headCapoPlugin) {
addPlugin({ src: resolve(runtimeDir, 'plugins/capo') })
}

// Add library-specific plugin
addPlugin({ src: resolve(runtimeDir, 'plugins/unhead') })
}
Expand Down
9 changes: 9 additions & 0 deletions packages/nuxt/src/head/runtime/plugins/capo.ts
@@ -0,0 +1,9 @@
import { CapoPlugin, injectHead } from '@unhead/vue'
import { defineNuxtPlugin } from '#app/nuxt'

export default defineNuxtPlugin({
name: 'nuxt:head:capo',
setup () {
injectHead().use(CapoPlugin())
}
})
2 changes: 1 addition & 1 deletion packages/schema/package.json
Expand Up @@ -30,7 +30,7 @@
"@types/file-loader": "5.0.1",
"@types/pug": "2.0.6",
"@types/sass-loader": "8.0.5",
"@unhead/schema": "1.1.35",
"@unhead/schema": "1.2.1",
"@vitejs/plugin-vue": "4.2.3",
"@vitejs/plugin-vue-jsx": "3.0.1",
"@vue/compiler-core": "3.3.4",
Expand Down
7 changes: 6 additions & 1 deletion packages/schema/src/config/experimental.ts
Expand Up @@ -207,6 +207,11 @@ export default defineUntypedSchema({
* @see https://github.com/parcel-bundler/watcher
* @type {'chokidar' | 'parcel' | 'chokidar-granular'}
*/
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.
*/
headCapoPlugin: false
}
})
195 changes: 163 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/bundle.test.ts
Expand Up @@ -35,7 +35,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"64.4k"')

const modules = await analyzeSizes('node_modules/**/*', serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2330k"')
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2331k"')

const packages = modules.files
.filter(m => m.endsWith('package.json'))
Expand Down Expand Up @@ -95,7 +95,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"370k"')

const modules = await analyzeSizes('node_modules/**/*', serverDir)
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"591k"')
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"593k"')

const packages = modules.files
.filter(m => m.endsWith('package.json'))
Expand Down