Skip to content

Commit 0a9e935

Browse files
KawaiiZapicsxzz
andauthored
feat(tdesign): add esm option (#475)
Co-authored-by: 三咲智子 <[email protected]>
1 parent 7ce80a7 commit 0a9e935

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/core/resolvers/tdesign.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export interface TDesignResolverOptions {
1919
* @default false
2020
*/
2121
resolveIcons?: boolean
22+
23+
/**
24+
* whether to import ESM version
25+
* @default false
26+
*/
27+
esm?: boolean
2228
}
2329

2430
function getSideEffects(importName: string, options: TDesignResolverOptions): SideEffectsInfo | undefined {
@@ -80,11 +86,12 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
8086
type: 'component',
8187
resolve: (name: string) => {
8288
const { library = 'vue' } = options
89+
const importFrom = options.esm ? '/esm' : ''
8390

8491
if (options.resolveIcons && name.match(/[a-z]Icon$/)) {
8592
return {
8693
name,
87-
from: `tdesign-icons-${library}`,
94+
from: `tdesign-icons-${library}${importFrom}`,
8895
}
8996
}
9097

@@ -93,7 +100,7 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
93100

94101
return {
95102
name: importName,
96-
from: `tdesign-${library}`,
103+
from: `tdesign-${library}${importFrom}`,
97104
sideEffects: getSideEffects(importName, options),
98105
}
99106
}

0 commit comments

Comments
 (0)