Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use globs option cannot resolve index.vue #536

Merged
merged 2 commits into from Dec 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core/utils.ts
Expand Up @@ -111,7 +111,7 @@ export function stringifyComponentImport({ as: name, from: path, name: importNam
}

export function getNameFromFilePath(filePath: string, options: ResolvedOptions): string {
const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes } = options
const { resolvedDirs, directoryAsNamespace, globalNamespaces, collapseSamePrefixes, root } = options

const parsedFilePath = parse(slash(filePath))

Expand All @@ -130,6 +130,10 @@ export function getNameFromFilePath(filePath: string, options: ResolvedOptions):

// set parent directory as filename if it is index
if (filename === 'index' && !directoryAsNamespace) {
// when use `globs` option, `resolvedDirs` will always empty, and `folders` will also empty
if (isEmpty(folders))
folders = parsedFilePath.dir.slice(root.length + 1).split('/').filter(Boolean)

filename = `${folders.slice(-1)[0]}`
return filename
}
Expand Down