MCPcopy Create free account
hub / github.com/arktypeio/arktype / keyedModuleOf

Function keyedModuleOf

ark/aot/driver.ts:1223–1255  ·  view source on GitHub ↗
(
	tracked: TrackedPrecompiler,
	source: string,
	id: string,
	currentMtimeOf: (file: string) => number
)

Source from the content-addressed store, hash-verified

1221}
1222
1223const keyedModuleOf = (
1224 tracked: TrackedPrecompiler,
1225 source: string,
1226 id: string,
1227 currentMtimeOf: (file: string) => number
1228): KeyedModule => {
1229 const { precompiler, importsByFile } = tracked
1230 const files = precompiler.textClosureOf(id, file => {
1231 if (file === id) return precompiler.textImportsOf(source, id)
1232 const mtime = currentMtimeOf(file)
1233 if (mtime === -1) return []
1234 const cached = importsByFile[file]
1235 return cached?.[0] === mtime ?
1236 cached[1]
1237 : (importsByFile[file] = [
1238 mtime,
1239 precompiler.textImportsOf(
1240 precompiler.graph.host.readFile(file) ?? "",
1241 file
1242 )
1243 ])[1]
1244 })
1245 const transformed = transformedModuleOf(precompiler, source, id, tracked)
1246 for (const dependency of transformed?.dependencies ?? [])
1247 if (!files.includes(dependency)) files.push(dependency)
1248 return {
1249 code:
1250 transformed?.code && appendSourceMap(transformed.code, transformed.map),
1251 errors: transformed?.errors ?? [],
1252 warnings: transformed?.warnings ?? [],
1253 files
1254 }
1255}
1256
1257const precompiles = (precompiler: Precompiler, source: string, id: string) =>
1258 precompiler.checkHelpers || precompiler.importsArk(source, id)

Callers 1

precompileFunction · 0.85

Calls 7

appendSourceMapFunction · 0.90
currentMtimeOfFunction · 0.85
transformedModuleOfFunction · 0.85
textClosureOfMethod · 0.80
textImportsOfMethod · 0.80
readFileMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected