Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._options.moduleMap.getPackage(name, platform, true),
getPackageMainPath: this._getPackageMainPath,
},
moduleName,
platform,
);
return this._getFileResolvedModule(result);
} catch (error) {
if (error instanceof Resolver.FailedToResolvePathError) {
const {candidates} = error;
throw new UnableToResolveError(
path.relative(this._options.projectRoot, fromModule.path),
moduleName,
[
'\n\nNone of these files exist:',
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.file),
)}`,
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.dir),
)}`,
].join('\n'),
);
}
if (error instanceof Resolver.FailedToResolveNameError) {
const {
dirPaths,
extraPaths,
}: {
// $flowfixme these types are defined explicitly in FailedToResolveNameError but Flow refuses to recognize them here
dirPaths: $ReadOnlyArray,
extraPaths: $ReadOnlyArray,
moduleName,
platform,
);
return this._getFileResolvedModule(result);
} catch (error) {
if (error instanceof Resolver.FailedToResolvePathError) {
const {candidates} = error;
throw new UnableToResolveError(
path.relative(this._options.projectRoot, fromModule.path),
moduleName,
[
'\n\nNone of these files exist:',
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.file),
)}`,
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.dir),
)}`,
].join('\n'),
);
}
if (error instanceof Resolver.FailedToResolveNameError) {
const {
dirPaths,
extraPaths,
}: {
// $flowfixme these types are defined explicitly in FailedToResolveNameError but Flow refuses to recognize them here
dirPaths: $ReadOnlyArray,
extraPaths: $ReadOnlyArray,
...
} = error;
const displayDirPaths = dirPaths
moduleName,
platform
);
return this._getFileResolvedModule(result);
} catch (error) {
if (error instanceof Resolver.FailedToResolvePathError) {
const candidates = error.candidates;
throw new UnableToResolveError(
path.relative(this._options.projectRoot, fromModule.path),
moduleName,
[
"\n\nNone of these files exist:",
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.file)
)}`,
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.dir)
)}`
].join("\n")
);
}
if (error instanceof Resolver.FailedToResolveNameError) {
const dirPaths = error.dirPaths,
extraPaths = error.extraPaths;
const displayDirPaths = dirPaths
.filter(dirPath => this._options.dirExists(dirPath))
.map(dirPath => path.relative(this._options.projectRoot, dirPath))
.concat(extraPaths);
const hint = displayDirPaths.length ? " or in these directories:" : "";
throw new UnableToResolveError(
path.relative(this._options.projectRoot, fromModule.path),
this._options.moduleMap.getPackage(name, platform, true),
getPackageMainPath: this._getPackageMainPath
}),
moduleName,
platform
);
return this._getFileResolvedModule(result);
} catch (error) {
if (error instanceof Resolver.FailedToResolvePathError) {
const candidates = error.candidates;
throw new UnableToResolveError(
path.relative(this._options.projectRoot, fromModule.path),
moduleName,
[
"\n\nNone of these files exist:",
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.file)
)}`,
` * ${Resolver.formatFileCandidates(
this._removeRoot(candidates.dir)
)}`
].join("\n")
);
}
if (error instanceof Resolver.FailedToResolveNameError) {
const dirPaths = error.dirPaths,
extraPaths = error.extraPaths;
const displayDirPaths = dirPaths
.filter(dirPath => this._options.dirExists(dirPath))
.map(dirPath => path.relative(this._options.projectRoot, dirPath))
.concat(extraPaths);
constructor(opts: {|
+originModulePath: string,
+packageError: InvalidPackageError,
+targetModuleName: string,
|}) {
const perr = opts.packageError;
super(
`While trying to resolve module \`${opts.targetModuleName}\` from file ` +
`\`${opts.originModulePath}\`, the package ` +
`\`${perr.packageJsonPath}\` was successfully found. However, ` +
'this package itself specifies ' +
'a `main` module field that could not be resolved (' +
`\`${perr.mainPrefixPath}\`. Indeed, none of these files exist:\n\n` +
` * ${formatFileCandidates(perr.fileCandidates)}\n` +
` * ${formatFileCandidates(perr.indexCandidates)}`,
);
Object.assign(this, opts);
}
}
moduleName,
platform
);
return this._getFileResolvedModule(result);
} catch (error) {
if (error instanceof Resolver.FailedToResolvePathError) {
const candidates = error.candidates;
throw new UnableToResolveError(
fromModule.path,
moduleName,
[
`The module \`${moduleName}\` could not be found from \`${
fromModule.path
}\`. Indeed, none of these files exist:`,
` * \`${Resolver.formatFileCandidates(candidates.file)}\``,
` * \`${Resolver.formatFileCandidates(candidates.dir)}\``
].join("\n")
);
}
if (error instanceof Resolver.FailedToResolveNameError) {
const dirPaths = error.dirPaths,
extraPaths = error.extraPaths;
const displayDirPaths = dirPaths
.filter(dirPath => this._options.dirExists(dirPath))
.concat(extraPaths);
const hint = displayDirPaths.length ? " or in these directories:" : "";
throw new UnableToResolveError(
fromModule.path,
moduleName,
[
`Module \`${moduleName}\` does not exist in the Haste module map${hint}`
}),
moduleName,
platform
);
return this._getFileResolvedModule(result);
} catch (error) {
if (error instanceof Resolver.FailedToResolvePathError) {
const candidates = error.candidates;
throw new UnableToResolveError(
fromModule.path,
moduleName,
[
`The module \`${moduleName}\` could not be found from \`${
fromModule.path
}\`. Indeed, none of these files exist:`,
` * \`${Resolver.formatFileCandidates(candidates.file)}\``,
` * \`${Resolver.formatFileCandidates(candidates.dir)}\``
].join("\n")
);
}
if (error instanceof Resolver.FailedToResolveNameError) {
const dirPaths = error.dirPaths,
extraPaths = error.extraPaths;
const displayDirPaths = dirPaths
.filter(dirPath => this._options.dirExists(dirPath))
.concat(extraPaths);
const hint = displayDirPaths.length ? " or in these directories:" : "";
throw new UnableToResolveError(
fromModule.path,
moduleName,
[
constructor(opts: {|
+originModulePath: string,
+packageError: InvalidPackageError,
+targetModuleName: string,
|}) {
const perr = opts.packageError;
super(
`While trying to resolve module \`${opts.targetModuleName}\` from file ` +
`\`${opts.originModulePath}\`, the package ` +
`\`${perr.packageJsonPath}\` was successfully found. However, ` +
'this package itself specifies ' +
'a `main` module field that could not be resolved (' +
`\`${perr.mainPrefixPath}\`. Indeed, none of these files exist:\n\n` +
` * ${formatFileCandidates(perr.fileCandidates)}\n` +
` * ${formatFileCandidates(perr.indexCandidates)}`,
);
Object.assign(this, opts);
}
}