From 977a40ed04209fc7f792de9bb989df353873cfe8 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 26 Nov 2015 05:33:38 -0800 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20error=20for=20known=20files=20t?= =?UTF-8?q?hat=20are=20reported=20as=20=E2=80=9Cadded=E2=80=9D=20by=20watc?= =?UTF-8?q?hman?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed By: tadeuzagallo Differential Revision: D2696636 fb-gh-sync-id: 89f90aba2a22d9c3e93632df4c4bc01791525833 --- .../DependencyGraph/HasteMap.js | 6 ++-- .../__tests__/DependencyGraph-test.js | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js b/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js index e1626fef8..38d27e3e3 100644 --- a/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js +++ b/packager/react-packager/src/DependencyResolver/DependencyGraph/HasteMap.js @@ -7,7 +7,6 @@ * of patent rights can be found in the PATENTS file in the same directory. */ 'use strict'; - const path = require('path'); const getPlatformExtension = require('../lib/getPlatformExtension'); const Promise = require('promise'); @@ -118,11 +117,12 @@ class HasteMap { const moduleMap = this._map[name]; const modulePlatform = getPlatformExtension(mod.path) || GENERIC_PLATFORM; + const existingModule = moduleMap[modulePlatform]; - if (moduleMap[modulePlatform]) { + if (existingModule && existingModule.path !== mod.path) { throw new Error( `Naming collision detected: ${mod.path} ` + - `collides with ${moduleMap[modulePlatform].path}` + `collides with ${existingModule.path}` ); } diff --git a/packager/react-packager/src/DependencyResolver/DependencyGraph/__tests__/DependencyGraph-test.js b/packager/react-packager/src/DependencyResolver/DependencyGraph/__tests__/DependencyGraph-test.js index a89ce97aa..d830cc825 100644 --- a/packager/react-packager/src/DependencyResolver/DependencyGraph/__tests__/DependencyGraph-test.js +++ b/packager/react-packager/src/DependencyResolver/DependencyGraph/__tests__/DependencyGraph-test.js @@ -3821,6 +3821,36 @@ describe('DependencyGraph', function() { }); }); }); + + pit('should not error when the watcher reports a known file as added', function() { + var root = '/root'; + fs.__setMockFilesystem({ + 'root': { + 'index.js': [ + '/**', + ' * @providesModule index', + ' */', + 'var b = require("b");', + ].join('\n'), + 'b.js': [ + '/**', + ' * @providesModule b', + ' */', + 'module.exports = function() {};', + ].join('\n'), + }, + }); + + var dgraph = new DependencyGraph({ + ...defaults, + roots: [root], + }); + + return getOrderedDependenciesAsJSON(dgraph, '/root/index.js').then(function() { + triggerFileChange('add', 'index.js', root, mockStat); + return getOrderedDependenciesAsJSON(dgraph, '/root/index.js'); + }); + }); }); describe('getAsyncDependencies', () => {