fix(nuxt): treeshake client-only components with placeholders (#8789)

This commit is contained in:
Julien Huang 2023-02-04 16:36:03 +01:00 committed by GitHub
parent 8a2b7810b5
commit bf617c790c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import type { Node } from 'ultrahtml'
import { parse, walk, ELEMENT_NODE } from 'ultrahtml'
import { createUnplugin } from 'unplugin'
import type { Component } from '@nuxt/schema'
import { resolve } from 'pathe'
import { distDir } from '../dirs'
interface TreeShakeTemplatePluginOptions {
sourcemap?: boolean
@ -30,7 +32,7 @@ export const TreeShakeTemplatePlugin = createUnplugin((options: TreeShakeTemplat
if (!regexpMap.has(components)) {
const clientOnlyComponents = components
.filter(c => c.mode === 'client' && !components.some(other => other.mode !== 'client' && other.pascalName === c.pascalName))
.filter(c => c.mode === 'client' && !components.some(other => other.mode !== 'client' && other.pascalName === c.pascalName && other.filePath !== resolve(distDir, 'app/components/server-placeholder')))
.flatMap(c => [c.pascalName, c.kebabName])
.concat(['ClientOnly', 'client-only'])
const tags = clientOnlyComponents