mirror of https://github.com/status-im/metro.git
Fix resolveNodeDependency for Windows
Summary: Related to https://github.com/zalmoxisus/remote-redux-devtools/issues/62, we got the wrong resolved path on Windows, should use `path.sep` instead of `'/'`. Closes https://github.com/facebook/react-native/pull/12206 Differential Revision: D4513338 fbshipit-source-id: 17814920986d091a6c6deae648f951f7be1cb688
This commit is contained in:
parent
a317b9da6c
commit
5f99af011a
|
@ -316,10 +316,10 @@ class ResolutionRequest {
|
||||||
|
|
||||||
if (isRelativeImport(realModuleName) || isAbsolutePath(realModuleName)) {
|
if (isRelativeImport(realModuleName) || isAbsolutePath(realModuleName)) {
|
||||||
// derive absolute path /.../node_modules/fromModuleDir/realModuleName
|
// derive absolute path /.../node_modules/fromModuleDir/realModuleName
|
||||||
const fromModuleParentIdx = fromModule.path.lastIndexOf('node_modules/') + 13;
|
const fromModuleParentIdx = fromModule.path.lastIndexOf('node_modules' + path.sep) + 13;
|
||||||
const fromModuleDir = fromModule.path.slice(
|
const fromModuleDir = fromModule.path.slice(
|
||||||
0,
|
0,
|
||||||
fromModule.path.indexOf('/', fromModuleParentIdx),
|
fromModule.path.indexOf(path.sep, fromModuleParentIdx),
|
||||||
);
|
);
|
||||||
const absPath = path.join(fromModuleDir, realModuleName);
|
const absPath = path.join(fromModuleDir, realModuleName);
|
||||||
return this._resolveFileOrDir(fromModule, absPath);
|
return this._resolveFileOrDir(fromModule, absPath);
|
||||||
|
@ -339,7 +339,7 @@ class ResolutionRequest {
|
||||||
|
|
||||||
if (this._extraNodeModules) {
|
if (this._extraNodeModules) {
|
||||||
const {_extraNodeModules} = this;
|
const {_extraNodeModules} = this;
|
||||||
const bits = toModuleName.split('/');
|
const bits = toModuleName.split(path.sep);
|
||||||
const packageName = bits[0];
|
const packageName = bits[0];
|
||||||
if (_extraNodeModules[packageName]) {
|
if (_extraNodeModules[packageName]) {
|
||||||
bits[0] = _extraNodeModules[packageName];
|
bits[0] = _extraNodeModules[packageName];
|
||||||
|
|
Loading…
Reference in New Issue