xplat/js/metro: DependencyGraph: reject on duplicate modules

Reviewed By: davidaurelio

Differential Revision: D7398617

fbshipit-source-id: eaac785d94b827502c2c50d8ec53ae251547a8a5
This commit is contained in:
Jean Lauliac 2018-04-03 09:24:27 -07:00 committed by Facebook Github Bot
parent 01599ed55e
commit 72a66fa8e4
2 changed files with 14 additions and 19 deletions

View File

@ -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'; const root = '/root';
console.warn = jest.fn(); console.warn = jest.fn();
setMockFileSystem({ setMockFileSystem({
@ -981,24 +981,18 @@ describe('traverseDependencies', function() {
const opts = {...defaults, projectRoots: [root]}; const opts = {...defaults, projectRoots: [root]};
// FIXME: This is broken, jest-haste-map does not fatal on modules with try {
// the same name, because not fataling was required for supporting some await processDgraph(opts, async dgraph => {});
// OSS projects. We'd like to enable it someday. throw new Error('should be unreachable');
} catch (error) {
//try { expect(error.message).toEqual(
await processDgraph(opts, async dgraph => {}); `jest-haste-map: @providesModule naming collision:\n` +
// throw new Error('should be unreachable'); ` Duplicate module name: index\n` +
// } catch (error) { ` Paths: /root/b.js collides with /root/index.js\n\n` +
// expect(error.message).toEqual( 'This error is caused by a @providesModule declaration ' +
// `Failed to build DependencyGraph: @providesModule naming collision:\n` + 'with the same name across two different files.',
// ` 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();
// }
}); });
it('throws when a module is missing', async () => { it('throws when a module is missing', async () => {

View File

@ -119,6 +119,7 @@ class DependencyGraph extends EventEmitter {
resetCache: opts.resetCache, resetCache: opts.resetCache,
retainAllFiles: true, retainAllFiles: true,
roots: opts.projectRoots, roots: opts.projectRoots,
throwOnModuleCollision: true,
useWatchman, useWatchman,
watch: opts.watch, watch: opts.watch,
}); });