mirror of https://github.com/status-im/metro.git
xplat/js/metro: DependencyGraph: reject on duplicate modules
Reviewed By: davidaurelio Differential Revision: D7398617 fbshipit-source-id: eaac785d94b827502c2c50d8ec53ae251547a8a5
This commit is contained in:
parent
01599ed55e
commit
72a66fa8e4
|
@ -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 {
|
||||
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();
|
||||
// }
|
||||
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 () => {
|
||||
|
|
|
@ -119,6 +119,7 @@ class DependencyGraph extends EventEmitter {
|
|||
resetCache: opts.resetCache,
|
||||
retainAllFiles: true,
|
||||
roots: opts.projectRoots,
|
||||
throwOnModuleCollision: true,
|
||||
useWatchman,
|
||||
watch: opts.watch,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue