MCPcopy
hub / github.com/PlasmoHQ/plasmo / handleAbsoluteRoot

Function handleAbsoluteRoot

core/parcel-resolver/src/handle-absolute-root.ts:11–45  ·  view source on GitHub ↗
({
  specifier,
  dependency
}: ResolverProps)

Source from the content-addressed store, hash-verified

9} from "./shared"
10
11export async function handleAbsoluteRoot({
12 specifier,
13 dependency
14}: ResolverProps): Promise<ResolverResult> {
15 if (specifier[0] !== "/") {
16 return null
17 }
18
19 if (pathExistsSync(specifier)) {
20 return {
21 filePath: specifier
22 }
23 }
24
25 const absoluteBaseFile = resolve(
26 join(process.env.PLASMO_PROJECT_DIR, specifier.slice(1))
27 )
28
29 const importExt = extname(absoluteBaseFile)
30
31 if (importExt.length > 0 && pathExistsSync(absoluteBaseFile)) {
32 return {
33 filePath: absoluteBaseFile
34 }
35 }
36
37 const parentExt = extname(dependency.resolveFrom)
38
39 const checkingExts = [
40 parentExt,
41 ...relevantExtensionList.filter((ext) => ext !== parentExt)
42 ]
43
44 return resolveSourceIndex(absoluteBaseFile, checkingExts)
45}

Callers 1

resolveFunction · 0.90

Calls 2

resolveSourceIndexFunction · 0.90
resolveFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…