Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// give request and point it to a completely different, unknown file. The
// last thing we've wanted to do the actual resolving, so we're going to
// rely on the `metro-resolver` module for that..
//
// Unfortunately, there's an issue, as we've set a `resolveRequest`
// function the resolver function thinks it needs to use that resolver to
// resolve the file, leading to an infinite loop, pain, suffering. So
// before we can continue, we need to check if we should remove our
// self from the context so the resolver works as intended again.
//
if (context.resolveRequest === resolveRequest) {
context.resolveRequest = null;
}
debug(`resovling file(${file})`);
return resolve(context, file, platform);
};
resolveDependency(fromModule, moduleName, allowHaste, platform) {
try {
const result = Resolver.resolve(
_objectSpread({}, this._options, {
originModulePath: fromModule.path,
redirectModulePath: modulePath =>
this._redirectRequire(fromModule, modulePath),
allowHaste,
platform,
resolveHasteModule: name =>
this._options.moduleMap.getModule(name, platform, true),
resolveHastePackage: name =>
this._options.moduleMap.getPackage(name, platform, true),
getPackageMainPath: this._getPackageMainPath
}),
moduleName,
platform
);
return this._getFileResolvedModule(result);
resolveDependency(
fromModule: TModule,
moduleName: string,
allowHaste: boolean,
platform: string | null,
): TModule {
try {
const result = Resolver.resolve(
{
...this._options,
originModulePath: fromModule.path,
redirectModulePath: (modulePath: string) =>
this._redirectRequire(fromModule, modulePath),
allowHaste,
platform,
resolveHasteModule: (name: string) =>
this._options.moduleMap.getModule(name, platform, true),
resolveHastePackage: (name: string) =>
this._options.moduleMap.getPackage(name, platform, true),
getPackageMainPath: this._getPackageMainPath,
},
moduleName,
platform,
);
resolveDependency(fromModule, moduleName, allowHaste, platform) {
try {
const result = Resolver.resolve(
_objectSpread({}, this._options, {
originModulePath: fromModule.path,
redirectModulePath: modulePath =>
this._redirectRequire(fromModule, modulePath),
allowHaste,
platform,
resolveHasteModule: name =>
this._options.moduleMap.getModule(name, platform, true),
resolveHastePackage: name =>
this._options.moduleMap.getPackage(name, platform, true),
getPackageMainPath: this._getPackageMainPath
}),
moduleName,
platform
);
return this._getFileResolvedModule(result);