Skip to content

Commit 07a63aa

Browse files
committed
refactor: avoid using getComponentPath in config
1 parent 8007173 commit 07a63aa

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as AllComponents from 'element-plus'
22
import * as AllIcons from '@element-plus/icons-vue'
33
import type { ElIdInjectionContext, ElZIndexInjectionContext } from 'element-plus'
44
import type { Component } from 'vue'
5-
import { getComponentPath } from './core/components'
65
import { isVueComponent } from './utils'
76
import type { ModuleOptions, PresetDirectives, PresetImport } from './types'
87

@@ -29,11 +28,7 @@ export const allImportsWithStyle: string[] = [
2928
'ElNotification'
3029
]
3130

32-
const allImports: PresetImport[] = [
33-
...allImportsWithStyle.map((name) => {
34-
return [name, getComponentPath(name)] as PresetImport
35-
})
36-
]
31+
const allImports: PresetImport[] = []
3732

3833
const allBaseImports: PresetImport[] = [
3934
['ID_INJECTION_KEY', 'es/hooks/use-id/index.mjs'],

src/core/imports.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { addImportsSources } from '@nuxt/kit'
2-
import { iconLibraryName, libraryName } from '../config'
2+
import { allImportsWithStyle, iconLibraryName, libraryName } from '../config'
33
import { genIconPresets, resolvePath, toArray } from '../utils'
44
import type { ModuleOptions, PresetImport } from '../types'
5+
import { getComponentPath } from './index'
56

67
function _resolveImports (imports: Set<PresetImport>) {
78
imports.forEach(async ([name, path]) => {
@@ -15,7 +16,10 @@ function _resolveImports (imports: Set<PresetImport>) {
1516
export async function resolveImports (config: ModuleOptions) {
1617
const { imports, icon } = config
1718
const icons = icon !== false ? genIconPresets(icon) : []
18-
const allImports = new Set(imports)
19+
const importsWithStyle = allImportsWithStyle.map((name) => {
20+
return [name, getComponentPath(name)] as PresetImport
21+
})
22+
const allImports = new Set([...imports, ...importsWithStyle])
1923
const allIcons = new Set(icons)
2024

2125
_resolveImports(allImports)

0 commit comments

Comments
 (0)