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

Function findImport

src/javascript/imports.ts:80–92  ·  view source on GitHub ↗
(node: ImportNode | ExportNode)

Source from the content-addressed store, hash-verified

78 }
79
80 function findImport(node: ImportNode | ExportNode) {
81 const source = node.source;
82 if (!source || !isStringLiteral(source)) return;
83 const name = decodeURI(getStringLiteralValue(source));
84 const method = node.type === "ImportExpression" ? "dynamic" : "static";
85 if (isPathImport(name)) {
86 const localPath = resolveLocalPath(path, name);
87 if (!localPath) throw syntaxError(`non-local import: ${name}`, node, input); // prettier-ignore
88 addImport({name: relativePath(path, localPath), type: "local", method});
89 } else {
90 addImport({name, type: "global", method});
91 }
92 }
93
94 function findImportMetaResolve(node: CallExpression) {
95 const source = node.arguments[0];

Callers

nothing calls this directly

Calls 7

isStringLiteralFunction · 0.85
getStringLiteralValueFunction · 0.85
isPathImportFunction · 0.85
resolveLocalPathFunction · 0.85
syntaxErrorFunction · 0.85
addImportFunction · 0.85
relativePathFunction · 0.85

Tested by

no test coverage detected