import type { ImportMap, ScopesMap, SpecifierMap } from '@esmx/import'; /** * Import map with `imports` and `scopes` fully resolved. The optional * `integrity` field is layered on later by {@link createClientImportMap}. */ type ResolvedImportMap = Required>; export interface ImportMapManifest { name: string; exports: Record; scopes: Record>; /** * Emitted chunk files (keyed arbitrarily). Each chunk's `js` is a relative * path (e.g. "chunks/routes.xxx.mjs"). Used so a module's scope also covers * its code-split chunks, not just its export files. */ chunks?: Record; /** * Subresource Integrity hashes for this module's build output files. * Keys are relative file paths (e.g. "src/routes.xxx.mjs"), values are * integrity strings (e.g. "sha384-..."). Only present in production builds. */ integrity?: Record; } export interface GetImportMapOptions { manifests: readonly ImportMapManifest[]; getScope: (name: string, scope: string) => string; getFile: (name: string, file: string) => string; } export declare function createImportsMap(manifests: readonly ImportMapManifest[], getFile: (name: string, file: string) => string): SpecifierMap; export declare function createScopesMap(imports: SpecifierMap, manifests: readonly ImportMapManifest[], getScope: (name: string, scope: string) => string): ScopesMap; /** * Fixes the nested scope resolution issue in import maps across all browsers. * * Import Maps have a cross-browser issue where nested scopes are not resolved correctly. * For example, when you have both "/shared-modules/" and "/shared-modules/vue2/" scopes, * browsers fail to properly apply the more specific nested scope. * * This function works around the issue by: * 1. Sorting scopes by path depth (shallow paths first, deeper paths last) * 2. Manually applying scopes to matching imports in the correct order * 3. Converting pattern-based scopes to concrete path scopes * * @example * Problematic import map that fails in browsers: * ```json * { * "scopes": { * "/shared-modules/": { * "vue": "/shared-modules/vue.d8c7a640.final.mjs" * }, * "/shared-modules/vue2/": { * "vue": "/shared-modules/vue2.9b4efaf3.final.mjs" * } * } * } * ``` * * @see https://github.com/guybedford/es-module-shims/issues/529 * @see https://issues.chromium.org/issues/453147451 */ export declare function fixImportMapNestedScopes(importMap: ResolvedImportMap): ResolvedImportMap; export declare function compressImportMap(importMap: ResolvedImportMap): ImportMap; export declare function createImportMap({ manifests, getFile, getScope }: GetImportMapOptions): ResolvedImportMap; export declare function createClientImportMap(options: GetImportMapOptions): ImportMap; export {};