diff --git a/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js b/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js index c866af1c..c8786614 100644 --- a/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js +++ b/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-integration-test.js @@ -969,7 +969,7 @@ describe('traverseDependencies', function() { }); }); - it('should fatal on multiple modules with the same name (actually broken)', async () => { + it('should fatal on multiple modules with the same name', async () => { const root = '/root'; console.warn = jest.fn(); setMockFileSystem({ @@ -981,24 +981,18 @@ describe('traverseDependencies', function() { const opts = {...defaults, projectRoots: [root]}; - // FIXME: This is broken, jest-haste-map does not fatal on modules with - // the same name, because not fataling was required for supporting some - // OSS projects. We'd like to enable it someday. - - //try { - await processDgraph(opts, async dgraph => {}); - // throw new Error('should be unreachable'); - // } catch (error) { - // expect(error.message).toEqual( - // `Failed to build DependencyGraph: @providesModule naming collision:\n` + - // ` Duplicate module name: index\n` + - // ` Paths: /root/b.js collides with /root/index.js\n\n` + - // 'This error is caused by a @providesModule declaration ' + - // 'with the same name across two different files.', - // ); - // expect(error.type).toEqual('DependencyGraphError'); - // expect(console.warn).toBeCalled(); - // } + try { + await processDgraph(opts, async dgraph => {}); + throw new Error('should be unreachable'); + } catch (error) { + expect(error.message).toEqual( + `jest-haste-map: @providesModule naming collision:\n` + + ` Duplicate module name: index\n` + + ` Paths: /root/b.js collides with /root/index.js\n\n` + + 'This error is caused by a @providesModule declaration ' + + 'with the same name across two different files.', + ); + } }); it('throws when a module is missing', async () => { diff --git a/packages/metro/src/node-haste/DependencyGraph.js b/packages/metro/src/node-haste/DependencyGraph.js index c5c669e9..999fe733 100644 --- a/packages/metro/src/node-haste/DependencyGraph.js +++ b/packages/metro/src/node-haste/DependencyGraph.js @@ -119,6 +119,7 @@ class DependencyGraph extends EventEmitter { resetCache: opts.resetCache, retainAllFiles: true, roots: opts.projectRoots, + throwOnModuleCollision: true, useWatchman, watch: opts.watch, });