mirror of https://github.com/status-im/metro.git
packager: ResolutionRequest: empty module is special case
Summary: Because we don't want to test for `empty-module.ios.js`, etc. We know the module is supposed to be here. This simpler version makes it easier for me to switch the rest of the `loadAsFile` callsites to the "candidates" system to the "candidates" system. Reviewed By: davidaurelio Differential Revision: D5103816 fbshipit-source-id: 7e7d9be27573a1f33d562aeb850759e073fbc72f
This commit is contained in:
parent
307eede076
commit
91fdb10abf
|
@ -481,11 +481,7 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
|||
potentialModulePath,
|
||||
);
|
||||
if (realModuleName === false) {
|
||||
return this._loadAsFileOrThrow(
|
||||
ResolutionRequest.EMPTY_MODULE,
|
||||
fromModule,
|
||||
toModuleName,
|
||||
);
|
||||
return this._getEmptyModule(fromModule, toModuleName);
|
||||
}
|
||||
|
||||
return tryResolveSync(
|
||||
|
@ -501,11 +497,7 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
|||
const realModuleName = this._redirectRequire(fromModule, toModuleName);
|
||||
// exclude
|
||||
if (realModuleName === false) {
|
||||
return this._loadAsFileOrThrow(
|
||||
ResolutionRequest.EMPTY_MODULE,
|
||||
fromModule,
|
||||
toModuleName,
|
||||
);
|
||||
return this._getEmptyModule(fromModule, toModuleName);
|
||||
}
|
||||
|
||||
if (isRelativeImport(realModuleName) || isAbsolutePath(realModuleName)) {
|
||||
|
@ -720,6 +712,19 @@ class ResolutionRequest<TModule: Moduleish, TPackage: Packageish> {
|
|||
return resolver.tryToResolveFileName(fileName) ? fileName : null;
|
||||
}
|
||||
|
||||
_getEmptyModule(fromModule: TModule, toModuleName: string): TModule {
|
||||
const {moduleCache} = this._options;
|
||||
const module = moduleCache.getModule(ResolutionRequest.EMPTY_MODULE);
|
||||
if (module != null) {
|
||||
return module;
|
||||
}
|
||||
throw new UnableToResolveError(
|
||||
fromModule,
|
||||
toModuleName,
|
||||
"could not resolve `${ResolutionRequest.EMPTY_MODULE}'",
|
||||
);
|
||||
}
|
||||
|
||||
_loadAsDir(
|
||||
potentialDirPath: string,
|
||||
fromModule: TModule,
|
||||
|
|
Loading…
Reference in New Issue