MCPcopy Create free account
hub / github.com/observablehq/framework / resolve

Function resolve

src/node.ts:138–146  ·  view source on GitHub ↗
(specifier: string | AstNode)

Source from the content-addressed store, hash-verified

136
137function importResolve(input: string, cacheRoot: string, packageRoot: string): Plugin {
138 async function resolve(specifier: string | AstNode): Promise<ResolveIdResult> {
139 return typeof specifier !== "string" || // AST node?
140 isNodeBuiltin(specifier) || // node built-in, e.g., "node:fs" or "fs"
141 isPathImport(specifier) || // relative path, e.g., ./foo.js
142 /^\0?[\w-]+:/.test(specifier) || // windows file path, https: URL, \x00node-resolve:, etc.
143 specifier === input // entry point
144 ? null // don’t do any additional resolution
145 : {id: await resolveNodeImportInternal(cacheRoot, packageRoot, specifier), external: true}; // resolve bare import
146 }
147 return {
148 name: "resolve-import",
149 resolveId: resolve,

Callers 14

registerFileFunction · 0.70
resolveSrcsetFunction · 0.70
rewriteImportSourceFunction · 0.70
withinFunction · 0.70
importResolveFunction · 0.70
resolveIdFunction · 0.70
getProjectIdMethod · 0.70
imageMethod · 0.50
observeFunction · 0.50
queueFunction · 0.50
connectFunction · 0.50

Calls 3

isNodeBuiltinFunction · 0.85
isPathImportFunction · 0.85

Tested by

no test coverage detected