MCPcopy
hub / github.com/nuxt/nuxt / resolveNuxtModule

Function resolveNuxtModule

packages/kit/src/resolve.ts:122–142  ·  view source on GitHub ↗
(base: string, paths: string[])

Source from the content-addressed store, hash-verified

120}
121
122export async function resolveNuxtModule (base: string, paths: string[]): Promise<string[]> {
123 const resolved: string[] = []
124 const resolver = createResolver(base)
125
126 for (const path of paths) {
127 if (path.startsWith(base)) {
128 resolved.push(path.split('/index.ts')[0]!)
129 continue
130 }
131 const resolvedPath = await resolver.resolvePath(path)
132 const dir = parseNodeModulePath(resolvedPath).dir
133 if (dir) {
134 resolved.push(dir)
135 continue
136 }
137 const index = resolvedPath.lastIndexOf(path)
138 resolved.push(index === -1 ? dirname(resolvedPath) : resolvedPath.slice(0, index + path.length))
139 }
140
141 return resolved
142}
143
144// --- Internal ---
145

Callers 3

bundleFunction · 0.90
resolve.test.tsFile · 0.90
_generateTypesFunction · 0.90

Calls 2

createResolverFunction · 0.85
resolvePathMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…