/** * Nested import detection and processing for module dependency resolution. * * @module transforms/mdx/esm-module-loader/module-fetcher/nested-imports */ import type { NestedImportResult } from "../types.js"; import { type DeferredImportErrorDescriptor } from "../utils/stub-module.js"; import type { Logger } from "../../../../utils/index.js"; type NestedImportSpan = { original: string; path: string; start: number; end: number; suffix?: string; isDynamic?: boolean; isSideEffect?: boolean; }; /** Return the sanitized runtime failure for a dependency error that can stay lazy. */ export declare function dynamicDependencyFailure(modulePath: string, error: unknown): DeferredImportErrorDescriptor | null; /** * Serialize a resolved module URL as a JavaScript string literal. * * A preserved suffix is author-controlled text (`?label="x"`, a backslash in a * cache path). Wrapping it in quotes by hand emits a module that fails to * parse, taking every other import in the file down with it, so every emitted * specifier must go through this. */ export declare function toImportStringLiteral(url: string): string; /** * Find nested module imports in code. * Matches both /_vf_modules/... and file:///_vf_modules/... patterns. */ export declare function findNestedImports(moduleCode: string): { vfModules: NestedImportSpan[]; relative: NestedImportSpan[]; }; /** * Check for unresolved /_vf_modules/ imports. */ export declare function hasUnresolvedImports(moduleCode: string): { count: number; paths: string[]; }; /** * Process nested imports by replacing them with file:// paths or stub modules. */ export declare function processNestedImports(moduleCode: string, results: NestedImportResult[], esmCacheDir: string, strictMissingModules: boolean, parentModulePath?: string, projectSlug?: string): Promise; export interface ResolveNestedModuleImportsInput { moduleCode: string; esmCacheDir: string; normalizedPath: string; projectSlug: string; strictMissingModules: boolean; fetchAndCacheModule: (path: string, parent?: string) => Promise; log?: Logger; /** * Path this module's relative imports resolve against. Defaults to * `normalizedPath`; see {@link resolveNestedImportBase}. */ parentBasePath?: string; } /** * The path a module's own relative imports should resolve against. * * A directory barrel lives at `lib/index.ts` but is addressed as * `_vf_modules/lib`. Resolving its children against `_vf_modules/lib.js` drops * the trailing segment as if it were a filename, so `./constants.js` becomes * `_vf_modules/constants.js`, one directory too high. The file is then not * found and gets replaced by a stub, and the barrel silently stops re-exporting * anything: `does not provide an export named 'COLORS'`. * * When the module actually resolved to an index file, keep the directory * segment by addressing it as `/index.js`. A path that already names its * own index file is left alone, whichever extension it carries: appending a * second `/index.js` would invent a directory that holds no files at all. */ export declare function resolveNestedImportBase(normalizedPath: string, actualFilePath?: string): string; /** * Resolve nested /_vf_modules and relative imports into local file:// cache paths. */ export declare function resolveNestedModuleImports(input: ResolveNestedModuleImportsInput): Promise; export {}; //# sourceMappingURL=nested-imports.d.ts.map