diff --git a/packages/metro/src/DeltaBundler/Serializers/hmrJSBundle.js b/packages/metro/src/DeltaBundler/Serializers/hmrJSBundle.js index 245a49c8de..5cee980c8d 100644 --- a/packages/metro/src/DeltaBundler/Serializers/hmrJSBundle.js +++ b/packages/metro/src/DeltaBundler/Serializers/hmrJSBundle.js @@ -31,6 +31,7 @@ function hmrJSBundle( options: Options, ): {| +modules: ModuleMap, + +deleted: $ReadOnlyArray, +sourceMappingURLs: $ReadOnlyArray, +sourceURLs: $ReadOnlyArray, |} { @@ -59,7 +60,12 @@ function hmrJSBundle( } } - return {modules, sourceMappingURLs, sourceURLs}; + return { + modules, + deleted: [...delta.deleted].map(path => options.createModuleId(path)), + sourceMappingURLs, + sourceURLs, + }; } function _prepareModule( diff --git a/packages/metro/src/HmrServer.js b/packages/metro/src/HmrServer.js index f14a3dce64..3e8ac80948 100644 --- a/packages/metro/src/HmrServer.js +++ b/packages/metro/src/HmrServer.js @@ -183,7 +183,7 @@ class HmrServer { client.revisionId = revision.id; - const {modules, sourceMappingURLs, sourceURLs} = hmrJSBundle( + const {modules, deleted, sourceMappingURLs, sourceURLs} = hmrJSBundle( delta, revision.graph, { @@ -197,6 +197,7 @@ class HmrServer { body: { revisionId: revision.id, modules, + deleted, sourceMappingURLs, sourceURLs, }, diff --git a/packages/metro/src/HmrServer/__tests__/HmrServer-test.js b/packages/metro/src/HmrServer/__tests__/HmrServer-test.js index e1b5e0d489..db758cd289 100644 --- a/packages/metro/src/HmrServer/__tests__/HmrServer-test.js +++ b/packages/metro/src/HmrServer/__tests__/HmrServer-test.js @@ -172,6 +172,7 @@ describe('HmrServer', () => { }, delta: { modified: new Map([['/root/hi', hiModule]]), + deleted: new Set(['/root/bye']), }, }), ); @@ -196,6 +197,7 @@ describe('HmrServer', () => { '__d(function() { alert("hi"); },"/root/hi-id",[],"hi",{});', ], ], + deleted: ['/root/bye-id'], sourceURLs: ['/root/hi'], }, }, diff --git a/packages/metro/src/lib/bundle-modules/types.flow.js b/packages/metro/src/lib/bundle-modules/types.flow.js index 8673390e9d..892fb95c79 100644 --- a/packages/metro/src/lib/bundle-modules/types.flow.js +++ b/packages/metro/src/lib/bundle-modules/types.flow.js @@ -36,6 +36,7 @@ export type FormattedError = {| export type HmrUpdate = {| +revisionId: string, +modules: ModuleMap, + +deleted: $ReadOnlyArray, +sourceMappingURLs: $ReadOnlyArray, +sourceURLs: $ReadOnlyArray, |};