getCommonBase() — vite Function Reference
Architecture documentation for the getCommonBase() function in importMetaGlob.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD b2546add_ed59_4395_9214_0c3fc0d07b41["getCommonBase()"] b68d9c02_4026_8cfa_8eb1_35ec4a8f23cb["importMetaGlob.ts"] b2546add_ed59_4395_9214_0c3fc0d07b41 -->|defined in| b68d9c02_4026_8cfa_8eb1_35ec4a8f23cb a6007673_0baa_9293_6af0_ff74ed056981["transformGlobImport()"] a6007673_0baa_9293_6af0_ff74ed056981 -->|calls| b2546add_ed59_4395_9214_0c3fc0d07b41 style b2546add_ed59_4395_9214_0c3fc0d07b41 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/plugins/importMetaGlob.ts lines 687–711
export function getCommonBase(globsResolved: string[]): null | string {
const bases = globsResolved
.filter((g) => g[0] !== '!')
.map((glob) => {
let { base } = picomatch.scan(glob)
// `scan('a/foo.js')` returns `base: 'a/foo.js'`
if (posix.basename(base).includes('.')) base = posix.dirname(base)
return base
})
if (!bases.length) return null
let commonAncestor = ''
const dirS = bases[0].split('/')
for (let i = 0; i < dirS.length; i++) {
const candidate = dirS.slice(0, i + 1).join('/')
if (bases.every((base) => base.startsWith(candidate)))
commonAncestor = candidate
else break
}
if (!commonAncestor) commonAncestor = '/'
return commonAncestor
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getCommonBase() do?
getCommonBase() is a function in the vite codebase, defined in packages/vite/src/node/plugins/importMetaGlob.ts.
Where is getCommonBase() defined?
getCommonBase() is defined in packages/vite/src/node/plugins/importMetaGlob.ts at line 687.
What calls getCommonBase()?
getCommonBase() is called by 1 function(s): transformGlobImport.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free