diff --git a/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-test.js b/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-test.js index 5fb4f684..cb648562 100644 --- a/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-test.js +++ b/packages/metro/src/DeltaBundler/__tests__/traverseDependencies-test.js @@ -276,4 +276,44 @@ describe('edge cases', () => { mockShallowDependencies('/bar', '/foo'); await assertOrder(); }); + + it('should simplify inlineRequires transform option', async () => { + jest.spyOn(dependencyGraph, 'getShallowDependencies'); + + const edges = new Map(); + const transformOptions = { + inlineRequires: { + blacklist: { + '/baz': true, + }, + }, + }; + + await initialTraverseDependencies( + '/bundle', + dependencyGraph, + transformOptions, + edges, + ); + + expect(dependencyGraph.getShallowDependencies.mock.calls).toEqual([ + ['/bundle', {inlineRequires: true}], + ['/foo', {inlineRequires: true}], + ['/bar', {inlineRequires: true}], + ['/baz', {inlineRequires: false}], + ]); + + dependencyGraph.getShallowDependencies.mockClear(); + + await traverseDependencies( + ['/foo'], + dependencyGraph, + transformOptions, + edges, + ); + + expect(dependencyGraph.getShallowDependencies.mock.calls).toEqual([ + ['/foo', {inlineRequires: true}], + ]); + }); }); diff --git a/packages/metro/src/DeltaBundler/traverseDependencies.js b/packages/metro/src/DeltaBundler/traverseDependencies.js index c63496c0..2a973a3e 100644 --- a/packages/metro/src/DeltaBundler/traverseDependencies.js +++ b/packages/metro/src/DeltaBundler/traverseDependencies.js @@ -112,7 +112,7 @@ async function traverseDependenciesForSingleFile( const shallow = await dependencyGraph.getShallowDependencies( path, - transformOptions, + removeInlineRequiresBlacklistFromOptions(path, transformOptions), ); // Get the absolute path of all sub-dependencies (some of them could have been