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

Function unbuiltReadOf

ark/aot/unplugin.ts:2215–2234  ·  view source on GitHub ↗
(
	{ moduleGraph: graph }: BundlerCompilation,
	written: readonly BuiltBundlerModule[]
)

Source from the content-addressed store, hash-verified

2213// keeps from happening unless webpack comes to defer them otherwise. Nothing
2214// else would say so, and the read would find it undefined
2215const unbuiltReadOf = (
2216 { moduleGraph: graph }: BundlerCompilation,
2217 written: readonly BuiltBundlerModule[]
2218): [file: string, name: string] | undefined => {
2219 for (const module of written) {
2220 const unbuilt = module.dependencies.flatMap(dependency =>
2221 (
2222 typeof dependency.name === "string" &&
2223 dependency.request !== undefined &&
2224 !graph.getModule(dependency as never)
2225 ) ?
2226 dependency.name
2227 : []
2228 )
2229 if (!unbuilt.length) continue
2230 const asked = namesAskedOf(graph, module)
2231 const read = unbuilt.find(name => asked === true || asked.has(name))
2232 if (read) return [fileOf(module.resource!), read]
2233 }
2234}
2235
2236// a request like `-!loader!./file` runs only the loader it names, so nothing the
2237// plugin writes of it reaches the bundle, which reads it as it was built

Callers 1

keepCompilerFunction · 0.85

Calls 4

fileOfFunction · 0.90
namesAskedOfFunction · 0.85
findMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected