Skip to content

Commit 3001083

Browse files
authored
feat: tdesign no need import sideEffects (unplugin#623)
1 parent c14f420 commit 3001083

File tree

1 file changed

+1
-72
lines changed

1 file changed

+1
-72
lines changed

src/core/resolvers/tdesign.ts

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
import type { ComponentResolver, SideEffectsInfo } from '../../types'
2-
import { kebabCase } from '../utils'
1+
import type { ComponentResolver } from '../../types'
32

43
export interface TDesignResolverOptions {
5-
/**
6-
* import style along with components
7-
* @default 'css'
8-
*/
9-
importStyle?: boolean | 'css' | 'less'
10-
114
/**
125
* select the specified library
136
* @default 'vue'
@@ -33,69 +26,6 @@ export interface TDesignResolverOptions {
3326
exclude?: string | RegExp | (string | RegExp)[]
3427
}
3528

36-
function getSideEffects(importName: string, options: TDesignResolverOptions): SideEffectsInfo | undefined {
37-
const { library = 'vue', importStyle = 'css' } = options
38-
let fileName = kebabCase(importName)
39-
40-
if (!importStyle)
41-
return
42-
43-
if (['config-provider', 'icon'].includes(fileName))
44-
return
45-
46-
if (fileName.includes('-') && fileName !== 'input-number') {
47-
const prefix = fileName.slice(0, fileName.indexOf('-'))
48-
const container = ['anchor', 'avatar', 'breadcrumb', 'checkbox', 'dropdown', 'form', 'input', 'list', 'menu', 'radio', 'slider', 'swiper', 'color-picker', 'text', 'collapse', 'timeline']
49-
50-
if (container.includes(prefix))
51-
fileName = prefix
52-
}
53-
54-
if (['row', 'col'].includes(fileName))
55-
fileName = 'grid'
56-
57-
if (fileName === 'addon')
58-
fileName = 'input'
59-
60-
if (['aside', 'layout', 'header', 'footer', 'content'].includes(fileName))
61-
fileName = 'layout'
62-
63-
if (['head-menu', 'submenu'].includes(fileName))
64-
fileName = 'menu'
65-
66-
if (['option', 'option-group'].includes(fileName))
67-
fileName = 'select'
68-
69-
if (['tab-nav', 'tab-panel'].includes(fileName))
70-
fileName = 'tabs'
71-
72-
if (fileName === 'step-item')
73-
fileName = 'steps'
74-
75-
if (fileName === 'check-tag')
76-
fileName = 'tag'
77-
78-
if (['time-range-picker', 'time-range-picker-panel', 'time-picker-panel'].includes(fileName))
79-
fileName = 'time-picker'
80-
81-
if (['date-range-picker', 'date-range-picker-panel', 'date-picker-panel'].includes(fileName))
82-
fileName = 'date-picker'
83-
84-
if (['color-picker', 'color-picker-panel'].includes(fileName))
85-
fileName = 'color-picker'
86-
87-
if (['enhanced-table', 'base-table'].includes(fileName))
88-
fileName = 'table'
89-
90-
if (['pagination-mini'].includes(fileName))
91-
fileName = 'pagination'
92-
93-
if (importStyle === 'less')
94-
return `tdesign-${library}/esm/${fileName}/style`
95-
96-
return `tdesign-${library}/es/${fileName}/style`
97-
}
98-
9929
export function TDesignResolver(options: TDesignResolverOptions = {}): ComponentResolver {
10030
return {
10131
type: 'component',
@@ -119,7 +49,6 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
11949
return {
12050
name: importName,
12151
from: `tdesign-${library}${importFrom}`,
122-
sideEffects: getSideEffects(importName, options),
12352
}
12453
}
12554
},

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy