From 5f99af011acba35a6ebf746c4910130ed43a2210 Mon Sep 17 00:00:00 2001 From: Jhen Date: Tue, 7 Feb 2017 12:35:12 -0800 Subject: [PATCH] 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 --- .../src/node-haste/DependencyGraph/ResolutionRequest.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js b/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js index ec0023ed..f8b690e6 100644 --- a/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js +++ b/packages/metro-bundler/src/node-haste/DependencyGraph/ResolutionRequest.js @@ -316,10 +316,10 @@ class ResolutionRequest { if (isRelativeImport(realModuleName) || isAbsolutePath(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( 0, - fromModule.path.indexOf('/', fromModuleParentIdx), + fromModule.path.indexOf(path.sep, fromModuleParentIdx), ); const absPath = path.join(fromModuleDir, realModuleName); return this._resolveFileOrDir(fromModule, absPath); @@ -339,7 +339,7 @@ class ResolutionRequest { if (this._extraNodeModules) { const {_extraNodeModules} = this; - const bits = toModuleName.split('/'); + const bits = toModuleName.split(path.sep); const packageName = bits[0]; if (_extraNodeModules[packageName]) { bits[0] = _extraNodeModules[packageName];