From 4647b62f4de9f41ade680bbb90da7d11e2c79547 Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Tue, 6 Sep 2016 08:52:17 -0700 Subject: [PATCH] fix(packager): support node-haste browser and react-native replacements on Windows Summary: Explain the **motivation** for making this change. What existing problem does the pull request solve? Fix issue with browser and react-native module mappings in node-haste when running the packager from Windows. **Test plan (required)** Tested on the NPM package uuid, which has a browser mapping, and it worked. Fixes #9570 Closes https://github.com/facebook/react-native/pull/9572 Differential Revision: D3821761 Pulled By: davidaurelio fbshipit-source-id: ebbd91f9e3215385afe3b81a97a962b45a6286f9 --- packager/react-packager/src/node-haste/Package.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packager/react-packager/src/node-haste/Package.js b/packager/react-packager/src/node-haste/Package.js index 07ffa5de9..5622e4120 100644 --- a/packager/react-packager/src/node-haste/Package.js +++ b/packager/react-packager/src/node-haste/Package.js @@ -58,7 +58,7 @@ class Package { return name; } - if (name[0] !== '/') { + if (!isAbsolutePath(name)) { const replacement = replacements[name]; // support exclude with "someDependency": false return replacement === false @@ -66,11 +66,11 @@ class Package { : replacement || name; } - if (!isAbsolutePath(name)) { - throw new Error(`Expected ${name} to be absolute path`); + let relPath = './' + path.relative(this.root, name); + if (path.sep !== '/') { + relPath = relPath.replace(path.sep, '/'); } - const relPath = './' + path.relative(this.root, name); let redirect = replacements[relPath]; // false is a valid value