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';
|
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 () => {
|
||||||
|
|
|
@ -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,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue