mirror of https://github.com/status-im/metro.git
packager: ResolutionRequest.js: sync _resolveFileOrDir
Reviewed By: davidaurelio Differential Revision: D4754138 fbshipit-source-id: d19792a726220a673dead1c8c6cdf487e34a6808
This commit is contained in:
parent
25c82f2e8c
commit
aec6307c4c
|
@ -302,22 +302,20 @@ class ResolutionRequest {
|
|||
});
|
||||
}
|
||||
|
||||
_redirectRequire(fromModule: Module, modulePath: string) {
|
||||
return Promise.resolve(fromModule.getPackage()).then(p => {
|
||||
if (p) {
|
||||
return p.redirectRequire(modulePath);
|
||||
_redirectRequire(fromModule: Module, modulePath: string): string | false {
|
||||
const pck = fromModule.getPackage();
|
||||
if (pck) {
|
||||
return pck.redirectRequire(modulePath);
|
||||
}
|
||||
return modulePath;
|
||||
});
|
||||
}
|
||||
|
||||
_resolveFileOrDir(fromModule: Module, toModuleName: string) {
|
||||
_resolveFileOrDir(fromModule: Module, toModuleName: string): Module {
|
||||
const potentialModulePath = isAbsolutePath(toModuleName) ?
|
||||
resolveWindowsPath(toModuleName) :
|
||||
path.join(path.dirname(fromModule.path), toModuleName);
|
||||
|
||||
return this._redirectRequire(fromModule, potentialModulePath).then(
|
||||
realModuleName => {
|
||||
const realModuleName = this._redirectRequire(fromModule, potentialModulePath);
|
||||
if (realModuleName === false) {
|
||||
return this._loadAsFile(
|
||||
ResolutionRequest.emptyModule,
|
||||
|
@ -331,15 +329,13 @@ class ResolutionRequest {
|
|||
() => this._loadAsDir(realModuleName, fromModule, toModuleName)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
_resolveNodeDependency(fromModule: Module, toModuleName: string) {
|
||||
_resolveNodeDependency(fromModule: Module, toModuleName: string): Promise<Module> {
|
||||
return Promise.resolve().then(() => {
|
||||
if (isRelativeImport(toModuleName) || isAbsolutePath(toModuleName)) {
|
||||
return this._resolveFileOrDir(fromModule, toModuleName);
|
||||
} else {
|
||||
return this._redirectRequire(fromModule, toModuleName).then(
|
||||
realModuleName => {
|
||||
}
|
||||
const realModuleName = this._redirectRequire(fromModule, toModuleName);
|
||||
// exclude
|
||||
if (realModuleName === false) {
|
||||
return this._loadAsFile(
|
||||
|
@ -416,7 +412,6 @@ class ResolutionRequest {
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_loadAsFile(potentialModulePath: string, fromModule: Module, toModule: string): Module {
|
||||
if (this._helpers.isAssetFile(potentialModulePath)) {
|
||||
|
|
Loading…
Reference in New Issue