( context: unknown, isTransformed: (id: string) => boolean )
| 2468 | // how a hook's bundler resolves an import the precompiler can't, like an alias |
| 2469 | // only its config names |
| 2470 | const 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 | |
| 2519 | const rollupScanOf = async ( |
| 2520 | context: RollupContext, |
no test coverage detected