metro-resolver
Advanced tools
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<ecc47d23741e55da9521abd0f088925f>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/createDefaultContext.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {ResolutionContext} from './types'; | ||
| import type {TransformResultDependency} from 'metro/private/DeltaBundler/types'; | ||
| type PartialContext = Readonly< | ||
| Omit< | ||
| ResolutionContext, | ||
| keyof {redirectModulePath?: ResolutionContext['redirectModulePath']} | ||
| > & {redirectModulePath?: ResolutionContext['redirectModulePath']} | ||
| >; | ||
| /** | ||
| * Helper used by the `metro` package to create the `ResolutionContext` object. | ||
| * As context values can be overridden by callers, this occurs externally to | ||
| * `resolve.js`. | ||
| */ | ||
| declare function createDefaultContext( | ||
| context: PartialContext, | ||
| dependency: TransformResultDependency, | ||
| ): ResolutionContext; | ||
| export default createDefaultContext; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<a36641315baa7d27d1b9ab17f41dbb35>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/FailedToResolveNameError.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| declare class FailedToResolveNameError extends Error { | ||
| dirPaths: ReadonlyArray<string>; | ||
| extraPaths: ReadonlyArray<string>; | ||
| constructor( | ||
| dirPaths: ReadonlyArray<string>, | ||
| extraPaths: ReadonlyArray<string>, | ||
| ); | ||
| } | ||
| export default FailedToResolveNameError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<1e0fa2d1bab2971504a4c271d453dc29>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/FailedToResolvePathError.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {FileAndDirCandidates} from '../types'; | ||
| declare class FailedToResolvePathError extends Error { | ||
| candidates: FileAndDirCandidates; | ||
| constructor(candidates: FileAndDirCandidates); | ||
| } | ||
| export default FailedToResolvePathError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<a8e62e3e6931f81d3849ddc01e077eda>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/FailedToResolveUnsupportedError.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| declare class FailedToResolveUnsupportedError extends Error { | ||
| constructor(message: string); | ||
| } | ||
| export default FailedToResolveUnsupportedError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<648dc80101f337456690a8a403891952>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/formatFileCandidates.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {FileCandidates} from '../types'; | ||
| declare function formatFileCandidates(candidates: FileCandidates): string; | ||
| export default formatFileCandidates; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<109d7323b70ba3a4582f5868df075ffc>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/InvalidPackageConfigurationError.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * Raised when a package contains an invalid `package.json` configuration. | ||
| */ | ||
| declare class InvalidPackageConfigurationError extends Error { | ||
| /** | ||
| * The description of the error cause. | ||
| */ | ||
| reason: string; | ||
| /** | ||
| * Absolute path of the package being resolved. | ||
| */ | ||
| packagePath: string; | ||
| constructor(opts: Readonly<{reason: string; packagePath: string}>); | ||
| } | ||
| export default InvalidPackageConfigurationError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<47b272bf4a763f5c68eed66346ee74e9>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/InvalidPackageError.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {FileCandidates} from '../types'; | ||
| declare class InvalidPackageError extends Error { | ||
| /** | ||
| * The file candidates we tried to find to resolve the `main` field of the | ||
| * package. Ex. `/js/foo/beep(.js|.json)?` if `main` is specifying `./beep` | ||
| * as the entry point. | ||
| */ | ||
| fileCandidates: FileCandidates; | ||
| /** | ||
| * The 'index' file candidates we tried to find to resolve the `main` field of | ||
| * the package. Ex. `/js/foo/beep/index(.js|.json)?` if `main` is specifying | ||
| * `./beep` as the entry point. | ||
| */ | ||
| indexCandidates: FileCandidates; | ||
| /** | ||
| * The full path to the main module that was attempted. | ||
| */ | ||
| mainModulePath: string; | ||
| /** | ||
| * Full path the package we were trying to resolve. | ||
| * Ex. `/js/foo/package.json`. | ||
| */ | ||
| packageJsonPath: string; | ||
| constructor(opts: { | ||
| readonly fileCandidates: FileCandidates; | ||
| readonly indexCandidates: FileCandidates; | ||
| readonly mainModulePath: string; | ||
| readonly packageJsonPath: string; | ||
| }); | ||
| } | ||
| export default InvalidPackageError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<5d012a93c58cbef8b5b315d70cb4fd5a>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/PackageImportNotResolvedError.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * Raised when package imports do not define or permit a target subpath in the | ||
| * package for the given import specifier. | ||
| */ | ||
| declare class PackageImportNotResolvedError extends Error { | ||
| /** | ||
| * Either the import specifier read, or the absolute path of the module being | ||
| * resolved (used when import specifier is externally remapped). | ||
| */ | ||
| readonly importSpecifier: string; | ||
| /** | ||
| * The description of the error cause. | ||
| */ | ||
| readonly reason: string; | ||
| constructor(opts: Readonly<{importSpecifier: string; reason: string}>); | ||
| } | ||
| export default PackageImportNotResolvedError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<f9f99f4d6c93fb36455e75fa72336e11>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/errors/PackagePathNotExportedError.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * Raised when package exports do not define or permit a target subpath in the | ||
| * package for the given module. | ||
| */ | ||
| declare class PackagePathNotExportedError extends Error {} | ||
| export default PackagePathNotExportedError; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<c26a662896a7bf2992a47a7daf457cbf>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/index.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| export type { | ||
| AssetFileResolution, | ||
| CustomResolutionContext, | ||
| CustomResolver, | ||
| CustomResolverOptions, | ||
| DoesFileExist, | ||
| FileAndDirCandidates, | ||
| FileCandidates, | ||
| FileResolution, | ||
| FileSystemLookup, | ||
| ResolutionContext, | ||
| Resolution, | ||
| ResolveAsset, | ||
| Result, | ||
| } from './types'; | ||
| import FailedToResolveNameError from './errors/FailedToResolveNameError'; | ||
| import FailedToResolvePathError from './errors/FailedToResolvePathError'; | ||
| import FailedToResolveUnsupportedError from './errors/FailedToResolveUnsupportedError'; | ||
| import formatFileCandidates from './errors/formatFileCandidates'; | ||
| import InvalidPackageError from './errors/InvalidPackageError'; | ||
| import resolve from './resolve'; | ||
| export { | ||
| FailedToResolveNameError, | ||
| FailedToResolvePathError, | ||
| FailedToResolveUnsupportedError, | ||
| formatFileCandidates, | ||
| InvalidPackageError, | ||
| resolve, | ||
| }; | ||
| /** | ||
| * Backwards-compatibility with CommonJS consumers using interopRequireDefault. | ||
| * Do not add to this list. | ||
| * | ||
| * @deprecated Default import from 'metro-resolver' is deprecated, use named exports. | ||
| */ | ||
| declare const $$EXPORT_DEFAULT_DECLARATION$$: { | ||
| FailedToResolveNameError: typeof FailedToResolveNameError; | ||
| FailedToResolvePathError: typeof FailedToResolvePathError; | ||
| FailedToResolveUnsupportedError: typeof FailedToResolveUnsupportedError; | ||
| formatFileCandidates: typeof formatFileCandidates; | ||
| InvalidPackageError: typeof InvalidPackageError; | ||
| resolve: typeof resolve; | ||
| }; | ||
| declare type $$EXPORT_DEFAULT_DECLARATION$$ = | ||
| typeof $$EXPORT_DEFAULT_DECLARATION$$; | ||
| export default $$EXPORT_DEFAULT_DECLARATION$$; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<7490133a41b70c6a0855b73fd990a5e3>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/PackageExportsResolve.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {ExportsField, FileResolution, ResolutionContext} from './types'; | ||
| /** | ||
| * Resolve a package subpath based on the entry points defined in the package's | ||
| * "exports" field. If there is no match for the given subpath (which may be | ||
| * augmented by resolution of conditional exports for the passed `context`), | ||
| * throws a `PackagePathNotExportedError`. | ||
| * | ||
| * Implements modern package resolution behaviour based on the [Package Entry | ||
| * Points spec](https://nodejs.org/docs/latest-v19.x/api/packages.html#package-entry-points). | ||
| * | ||
| * @throws {InvalidPackageConfigurationError} Raised if configuration specified | ||
| * by `exportsField` is invalid. | ||
| * @throws {InvalidModuleSpecifierError} Raised if the resolved module specifier | ||
| * is invalid. | ||
| * @throws {PackagePathNotExportedError} Raised when the requested subpath is | ||
| * not exported. | ||
| */ | ||
| export declare function resolvePackageTargetFromExports( | ||
| context: ResolutionContext, | ||
| packagePath: string, | ||
| modulePath: string, | ||
| packageRelativePath: string, | ||
| exportsField: ExportsField, | ||
| platform: string | null, | ||
| ): FileResolution; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<e23956477d8d1e5fef52de8eea8f091f>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/PackageImportsResolve.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {ExportsLikeMap, FileResolution, ResolutionContext} from './types'; | ||
| /** | ||
| * Resolve a package subpath based on the entry points defined in the package's | ||
| * "imports" field. If there is no match for the given subpath (which may be | ||
| * augmented by resolution of conditional exports for the passed `context`), | ||
| * throws a `PackagePathNotExportedError`. | ||
| * | ||
| * Implementation of PACKAGE_IMPORTS_RESOLVE described in https://nodejs.org/api/esm.html | ||
| * | ||
| * @throws {InvalidPackageConfigurationError} Raised if configuration specified | ||
| * by `importsMap` is invalid. | ||
| */ | ||
| export declare function resolvePackageTargetFromImports( | ||
| context: ResolutionContext, | ||
| packagePath: string, | ||
| importPath: string, | ||
| importsMap: ExportsLikeMap, | ||
| platform: string | null, | ||
| ): FileResolution; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<7e880beb8b73f4a072dfd248ff41d7b0>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/PackageResolve.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {PackageInfo, ResolutionContext} from './types'; | ||
| /** | ||
| * Resolve the main entry point subpath for a package. | ||
| * | ||
| * Implements legacy (non-exports) package resolution behaviour based on the | ||
| * ["browser" field spec](https://github.com/defunctzombie/package-browser-field-spec). | ||
| */ | ||
| export declare function getPackageEntryPoint( | ||
| context: ResolutionContext, | ||
| packageInfo: PackageInfo, | ||
| platform: string | null, | ||
| ): string; | ||
| /** | ||
| * Get the resolved file path for the given import specifier based on any | ||
| * `package.json` rules. Returns `false` if the module should be | ||
| * [ignored](https://github.com/defunctzombie/package-browser-field-spec#ignore-a-module), | ||
| * and returns the original path if no `package.json` mapping is matched. Does | ||
| * not test file existence. | ||
| * | ||
| * Implements legacy (non-exports) package resolution behaviour based on the | ||
| * ["browser" field spec](https://github.com/defunctzombie/package-browser-field-spec). | ||
| */ | ||
| export declare function redirectModulePath( | ||
| context: Readonly<{ | ||
| getPackageForModule: ResolutionContext['getPackageForModule']; | ||
| mainFields: ResolutionContext['mainFields']; | ||
| originModulePath: ResolutionContext['originModulePath']; | ||
| }>, | ||
| modulePath: string, | ||
| ): string | false; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<56f6e00225ee5ece6142bb2b9e4c608d>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/resolve.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {Resolution, ResolutionContext} from './types'; | ||
| declare function resolve( | ||
| context: ResolutionContext, | ||
| moduleName: string, | ||
| platform: string | null, | ||
| ): Resolution; | ||
| export default resolve; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<ee7db612dfb499aad9673000da2af870>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/resolveAsset.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {AssetResolution, ResolutionContext} from './types'; | ||
| /** | ||
| * Resolve a file path as an asset. Returns the set of files found after | ||
| * expanding asset resolutions (e.g. `icon@2x.png`). Users may override this | ||
| * behaviour via `context.resolveAsset`. | ||
| */ | ||
| declare function resolveAsset( | ||
| context: ResolutionContext, | ||
| filePath: string, | ||
| ): AssetResolution | null; | ||
| export default resolveAsset; |
+210
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<dc003cf249ff458402c66f8295b5c361>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/types.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {TransformResultDependency} from 'metro/private/DeltaBundler/types'; | ||
| export type Result<TResolution, TCandidates> = | ||
| | {readonly type: 'resolved'; readonly resolution: TResolution} | ||
| | {readonly type: 'failed'; readonly candidates: TCandidates}; | ||
| export type Resolution = FileResolution | {readonly type: 'empty'}; | ||
| export type SourceFileResolution = Readonly<{ | ||
| type: 'sourceFile'; | ||
| filePath: string; | ||
| }>; | ||
| export type AssetFileResolution = ReadonlyArray<string>; | ||
| export type AssetResolution = Readonly<{ | ||
| type: 'assetFiles'; | ||
| filePaths: AssetFileResolution; | ||
| }>; | ||
| export type FileResolution = AssetResolution | SourceFileResolution; | ||
| export type FileAndDirCandidates = { | ||
| readonly dir: null | undefined | FileCandidates; | ||
| readonly file: null | undefined | FileCandidates; | ||
| }; | ||
| /** | ||
| * This is a way to describe what files we tried to look for when resolving | ||
| * a module name as file. This is mainly used for error reporting, so that | ||
| * we can explain why we cannot resolve a module. | ||
| */ | ||
| export type FileCandidates = | ||
| | {readonly type: 'asset'; readonly name: string} | ||
| | { | ||
| readonly type: 'sourceFile'; | ||
| filePathPrefix: string; | ||
| readonly candidateExts: ReadonlyArray<string>; | ||
| }; | ||
| export type ExportsLikeMap = Readonly<{ | ||
| [subpathOrCondition: string]: string | ExportsLikeMap | null; | ||
| }>; | ||
| /** "exports" mapping where values may be legacy Node.js <13.7 array format. */ | ||
| export type ExportMapWithFallbacks = Readonly<{ | ||
| [subpath: string]: | ||
| | ExportsLikeMap[keyof ExportsLikeMap] | ||
| | ExportValueWithFallback; | ||
| }>; | ||
| /** "exports" subpath value when in legacy Node.js <13.7 array format. */ | ||
| export type ExportValueWithFallback = | ||
| | ReadonlyArray<ExportsLikeMap | string> | ||
| | ReadonlyArray<ReadonlyArray<unknown>>; | ||
| export type ExportsField = | ||
| | string | ||
| | ReadonlyArray<string> | ||
| | ExportValueWithFallback | ||
| | ExportsLikeMap | ||
| | ExportMapWithFallbacks; | ||
| export type FlattenedExportMap = ReadonlyMap<string, string | null>; | ||
| export type NormalizedExportsLikeMap = Map< | ||
| string, | ||
| null | string | ExportsLikeMap | ||
| >; | ||
| export type PackageJson = Readonly<{ | ||
| name?: string; | ||
| main?: string; | ||
| exports?: ExportsField; | ||
| imports?: ExportsLikeMap; | ||
| }>; | ||
| export type PackageInfo = Readonly<{ | ||
| packageJson: PackageJson; | ||
| rootPath: string; | ||
| }>; | ||
| export type PackageForModule = Readonly< | ||
| Omit<PackageInfo, keyof {packageRelativePath: string}> & { | ||
| packageRelativePath: string; | ||
| } | ||
| >; | ||
| /** | ||
| * Check existence of a single file. | ||
| */ | ||
| export type DoesFileExist = (filePath: string) => boolean; | ||
| /** | ||
| * Performs a lookup against an absolute or project-relative path to determine | ||
| * whether it exists as a file or directory. Follows any symlinks, and returns | ||
| * a real absolute path on existence. | ||
| */ | ||
| export type FileSystemLookup = ( | ||
| absoluteOrProjectRelativePath: string, | ||
| ) => {exists: false} | {exists: true; type: 'f' | 'd'; realPath: string}; | ||
| /** | ||
| * Given a directory path and the base asset name, return a list of all the | ||
| * asset file names that match the given base name in that directory. Return | ||
| * null if there's no such named asset. `platform` is used to identify | ||
| * platform-specific assets, ex. `foo.ios.js` instead of a generic `foo.js`. | ||
| */ | ||
| export type ResolveAsset = ( | ||
| dirPath: string, | ||
| assetName: string, | ||
| extension: string, | ||
| ) => null | undefined | ReadonlyArray<string>; | ||
| export type ResolutionContext = Readonly<{ | ||
| allowHaste: boolean; | ||
| assetExts: ReadonlySet<string>; | ||
| customResolverOptions: CustomResolverOptions; | ||
| disableHierarchicalLookup: boolean; | ||
| /** | ||
| * Determine whether a regular file exists at the given path. | ||
| * | ||
| * @deprecated, prefer `fileSystemLookup` | ||
| */ | ||
| doesFileExist: DoesFileExist; | ||
| extraNodeModules: null | undefined | {[$$Key$$: string]: string}; | ||
| /** Is resolving for a development bundle. */ | ||
| dev: boolean; | ||
| /** | ||
| * Get the parsed contents of the specified `package.json` file. | ||
| */ | ||
| getPackage: (packageJsonPath: string) => null | undefined | PackageJson; | ||
| /** | ||
| * Get the closest package scope, parsed `package.json` and relative subpath | ||
| * for a given absolute candidate path (which need not exist), or null if | ||
| * there is no package.json closer than the nearest node_modules directory. | ||
| * | ||
| * @deprecated See https://github.com/facebook/metro/commit/29c77bff31e2475a086bc3f04073f485da8f9ff0 | ||
| */ | ||
| getPackageForModule: ( | ||
| absoluteModulePath: string, | ||
| ) => null | undefined | PackageForModule; | ||
| /** | ||
| * The dependency descriptor, within the origin module, corresponding to the | ||
| * current resolution request. This is provided for diagnostic purposes ONLY | ||
| * and may not be used for resolution purposes. | ||
| */ | ||
| dependency?: TransformResultDependency; | ||
| /** | ||
| * Whether the dependency to be resolved was declared with an ESM import, | ||
| * ("import x from 'y'" or "await import('z')"), or a CommonJS "require". | ||
| * Corresponds to the criteria Node.js uses to assert an "import" | ||
| * resolution condition, vs "require". | ||
| * | ||
| * Always equal to dependency.data.isESMImport where dependency is provided, | ||
| * but may be used for resolution. | ||
| */ | ||
| isESMImport?: boolean; | ||
| /** | ||
| * Synchonously returns information about a given absolute path, including | ||
| * whether it exists, whether it is a file or directory, and its absolute | ||
| * real path. | ||
| */ | ||
| fileSystemLookup: FileSystemLookup; | ||
| /** | ||
| * The ordered list of fields to read in `package.json` to resolve a main | ||
| * entry point based on the "browser" field spec. | ||
| */ | ||
| mainFields: ReadonlyArray<string>; | ||
| /** | ||
| * Full path of the module that is requiring or importing the module to be | ||
| * resolved. This may not be the only place this dependency was found, | ||
| * as resolutions can be cached. | ||
| */ | ||
| originModulePath: string; | ||
| nodeModulesPaths: ReadonlyArray<string>; | ||
| preferNativePlatform: boolean; | ||
| resolveAsset: ResolveAsset; | ||
| redirectModulePath: (modulePath: string) => string | false; | ||
| /** | ||
| * Given a name, this should return the full path to the file that provides | ||
| * a Haste module of that name. Ex. for `Foo` it may return `/smth/Foo.js`. | ||
| */ | ||
| resolveHasteModule: (name: string) => null | undefined | string; | ||
| /** | ||
| * Given a name, this should return the full path to the package manifest that | ||
| * provides a Haste package of that name. Ex. for `Foo` it may return | ||
| * `/smth/Foo/package.json`. | ||
| */ | ||
| resolveHastePackage: (name: string) => null | undefined | string; | ||
| resolveRequest?: null | undefined | CustomResolver; | ||
| sourceExts: ReadonlyArray<string>; | ||
| unstable_conditionNames: ReadonlyArray<string>; | ||
| unstable_conditionsByPlatform: Readonly<{ | ||
| [platform: string]: ReadonlyArray<string>; | ||
| }>; | ||
| unstable_enablePackageExports: boolean; | ||
| unstable_incrementalResolution: boolean; | ||
| unstable_logWarning: (message: string) => void; | ||
| }>; | ||
| export type CustomResolutionContext = Readonly< | ||
| Omit<ResolutionContext, keyof {resolveRequest: CustomResolver}> & { | ||
| resolveRequest: CustomResolver; | ||
| } | ||
| >; | ||
| export type CustomResolver = ( | ||
| context: CustomResolutionContext, | ||
| moduleName: string, | ||
| platform: string | null, | ||
| ) => Resolution; | ||
| export type CustomResolverOptions = { | ||
| readonly [$$Key$$: string]: unknown; | ||
| }; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<ef11437df6220e26b38eae0d8fb2c3d1>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/utils/isAssetFile.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * Determine if a file path should be considered an asset file based on the | ||
| * given `assetExts`. | ||
| */ | ||
| declare function isAssetFile( | ||
| filePath: string, | ||
| assetExts: ReadonlySet<string>, | ||
| ): boolean; | ||
| export default isAssetFile; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<bf08da4ef625a52c96e6ab5e4b6b088a>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/utils/isSubpathDefinedInExportsLike.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * Identifies whether the given subpath is defined in the given "exports"-like | ||
| * mapping. Does not reduce exports conditions (therefore does not identify | ||
| * whether the subpath is mapped to a value). | ||
| */ | ||
| import type {NormalizedExportsLikeMap} from '../types'; | ||
| export declare function isSubpathDefinedInExportsLike( | ||
| exportsLikeMap: NormalizedExportsLikeMap, | ||
| subpath: string, | ||
| ): boolean; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<2de88d23d3cf26217cd8ae8ada6c79b7>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/utils/matchSubpathFromExportsLike.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| import type {NormalizedExportsLikeMap, ResolutionContext} from '../types'; | ||
| /** | ||
| * Get the mapped replacement for the given subpath. | ||
| * | ||
| * Implements modern package resolution behaviour based on the [Package Entry | ||
| * Points spec](https://nodejs.org/docs/latest-v19.x/api/packages.html#package-entry-points). | ||
| */ | ||
| export declare function matchSubpathFromExportsLike( | ||
| context: ResolutionContext, | ||
| subpath: string, | ||
| exportsLikeMap: NormalizedExportsLikeMap, | ||
| platform: string | null, | ||
| createConfigError: (reason: string) => Error, | ||
| ): Readonly<{target: string | null; patternMatch: string | null}>; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<40375a98e9c03360973e0cf65b702ced>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/utils/matchSubpathPattern.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * If a subpath pattern expands to the passed subpath, return the subpath match | ||
| * (value to substitute for '*'). Otherwise, return `null`. | ||
| * | ||
| * See https://nodejs.org/docs/latest-v19.x/api/packages.html#subpath-patterns. | ||
| */ | ||
| export declare function matchSubpathPattern( | ||
| subpathPattern: string, | ||
| subpath: string, | ||
| ): string | null; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<0bb41edd0d0c6f257cb95ca9b7b00aa9>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/utils/reduceExportsLikeMap.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * Reduce an "exports"-like mapping to a flat subpath mapping after resolving | ||
| * conditional exports. | ||
| */ | ||
| import type {FlattenedExportMap, NormalizedExportsLikeMap} from '../types'; | ||
| export declare function reduceExportsLikeMap( | ||
| exportsLikeMap: NormalizedExportsLikeMap, | ||
| conditionNames: ReadonlySet<string>, | ||
| createConfigError: (reason: string) => Error, | ||
| ): FlattenedExportMap; |
| /** | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * | ||
| * @noformat | ||
| * @oncall react_native | ||
| * @generated SignedSource<<091df9100cc8f841af449036a548f6aa>> | ||
| * | ||
| * This file was translated from Flow by scripts/generateTypeScriptDefinitions.js | ||
| * Original file: packages/metro-resolver/src/utils/toPosixPath.js | ||
| * To regenerate, run: | ||
| * js1 build metro-ts-defs (internal) OR | ||
| * yarn run build-ts-defs (OSS) | ||
| */ | ||
| /** | ||
| * Replace path separators in the passed string to coerce to a POSIX path. This | ||
| * is a no-op on POSIX systems. | ||
| */ | ||
| declare function toPosixPath(relativePathOrSpecifier: string): string; | ||
| export default toPosixPath; |
+2
-2
| { | ||
| "name": "metro-resolver", | ||
| "version": "0.84.1", | ||
| "version": "0.84.2", | ||
| "description": "🚇 Implementation of Metro's resolution logic.", | ||
@@ -25,3 +25,3 @@ "main": "src/index.js", | ||
| "devDependencies": { | ||
| "metro": "0.84.1" | ||
| "metro": "0.84.2" | ||
| }, | ||
@@ -28,0 +28,0 @@ "dependencies": { |
139441
27.99%68
47.83%2156
65.08%