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

Function bundlerResolveOf

ark/aot/unplugin.ts:2470–2517  ·  view source on GitHub ↗
(
	context: unknown,
	isTransformed: (id: string) => boolean
)

Source from the content-addressed store, hash-verified

2468// how a hook's bundler resolves an import the precompiler can't, like an alias
2469// only its config names
2470const bundlerResolveOf = (
2471 context: unknown,
2472 isTransformed: (id: string) => boolean
2473): BundlerResolve | undefined => {
2474 const rollup = context as Partial<RollupContext>
2475 if (rollup.resolve) {
2476 return async (specifier, importer) => {
2477 if (ownSpecifier.test(specifier)) return
2478 const resolved = await resolveUnloaded(
2479 rollup as RollupContext,
2480 specifier,
2481 importer,
2482 isTransformed,
2483 { skipSelf: true }
2484 )
2485 return (
2486 resolved &&
2487 !resolved.external &&
2488 isAbsolute(resolved.id) &&
2489 !resolved.id.includes("?")
2490 ) ?
2491 resolved.id
2492 : undefined
2493 }
2494 }
2495 // webpack and Rspack
2496 const loaderResolve = (
2497 context as {
2498 getNativeBuildContext?: () =>
2499 | {
2500 loaderContext?: {
2501 getResolve?: (options: {
2502 dependencyType: string
2503 }) => (context: string, request: string) => Promise<string>
2504 }
2505 }
2506 | undefined
2507 }
2508 )
2509 .getNativeBuildContext?.()
2510 ?.loaderContext?.getResolve?.({ dependencyType: "esm" })
2511 if (loaderResolve) {
2512 return async (specifier, importer) =>
2513 ownSpecifier.test(specifier) ? undefined : (
2514 loaderResolve(dirname(importer), specifier).catch(() => undefined)
2515 )
2516 }
2517}
2518
2519const rollupScanOf = async (
2520 context: RollupContext,

Callers 3

scanOfFunction · 0.85
handlerFunction · 0.85
buildEndFunction · 0.85

Calls 3

resolveUnloadedFunction · 0.85
testMethod · 0.80
getResolveMethod · 0.80

Tested by

no test coverage detected