diff --git a/packages/metro-bundler/src/DeltaBundler/DeltaCalculator.js b/packages/metro-bundler/src/DeltaBundler/DeltaCalculator.js index 68bb4e6f..42bd015f 100644 --- a/packages/metro-bundler/src/DeltaBundler/DeltaCalculator.js +++ b/packages/metro-bundler/src/DeltaBundler/DeltaCalculator.js @@ -167,6 +167,17 @@ class DeltaCalculator extends EventEmitter { type: string, filePath: string, }): mixed => { + // We do not want to keep track of deleted files, since this can cause + // issues when moving files (or even deleting files). + // The only issue with this approach is that the user removes a file that + // is needed, the bundler will still create a correct bundle (since it + // won't detect any modified file). Once we have our own dependency + // traverser in Delta Bundler this will be easy to fix. + if (type === 'delete') { + this._dependencies.delete(filePath); + return; + } + this._modifiedFiles.add(filePath); // Notify users that there is a change in some of the bundle files. This diff --git a/packages/metro-bundler/src/DeltaBundler/__tests__/DeltaCalculator-test.js b/packages/metro-bundler/src/DeltaBundler/__tests__/DeltaCalculator-test.js index 17fd4965..45bb2c68 100644 --- a/packages/metro-bundler/src/DeltaBundler/__tests__/DeltaCalculator-test.js +++ b/packages/metro-bundler/src/DeltaBundler/__tests__/DeltaCalculator-test.js @@ -235,6 +235,21 @@ describe('DeltaCalculator', () => { expect(onChangeFile.mock.calls.length).toBe(0); }); + it('should not emit an event when there is a file deleted', async () => { + jest.useFakeTimers(); + + const onChangeFile = jest.fn(); + await deltaCalculator.getDelta(); + + deltaCalculator.on('delete', onChangeFile); + + fileWatcher.emit('change', {eventsQueue: [{filePath: '/foo'}]}); + + jest.runAllTimers(); + + expect(onChangeFile.mock.calls.length).toBe(0); + }); + it('should retry to build the last delta after getting an error', async () => { await deltaCalculator.getDelta();