mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): treeshake client-only components with placeholders (#8789)
This commit is contained in:
parent
8a2b7810b5
commit
bf617c790c
@ -5,6 +5,8 @@ import type { Node } from 'ultrahtml'
|
|||||||
import { parse, walk, ELEMENT_NODE } from 'ultrahtml'
|
import { parse, walk, ELEMENT_NODE } from 'ultrahtml'
|
||||||
import { createUnplugin } from 'unplugin'
|
import { createUnplugin } from 'unplugin'
|
||||||
import type { Component } from '@nuxt/schema'
|
import type { Component } from '@nuxt/schema'
|
||||||
|
import { resolve } from 'pathe'
|
||||||
|
import { distDir } from '../dirs'
|
||||||
|
|
||||||
interface TreeShakeTemplatePluginOptions {
|
interface TreeShakeTemplatePluginOptions {
|
||||||
sourcemap?: boolean
|
sourcemap?: boolean
|
||||||
@ -30,7 +32,7 @@ export const TreeShakeTemplatePlugin = createUnplugin((options: TreeShakeTemplat
|
|||||||
|
|
||||||
if (!regexpMap.has(components)) {
|
if (!regexpMap.has(components)) {
|
||||||
const clientOnlyComponents = 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])
|
.flatMap(c => [c.pascalName, c.kebabName])
|
||||||
.concat(['ClientOnly', 'client-only'])
|
.concat(['ClientOnly', 'client-only'])
|
||||||
const tags = clientOnlyComponents
|
const tags = clientOnlyComponents
|
||||||
|
Loading…
Reference in New Issue
Block a user