diff --git a/packages/metro-bundler/src/Server/__tests__/Server-test.js b/packages/metro-bundler/src/Server/__tests__/Server-test.js index bcfb2cfc..5e32f529 100644 --- a/packages/metro-bundler/src/Server/__tests__/Server-test.js +++ b/packages/metro-bundler/src/Server/__tests__/Server-test.js @@ -67,6 +67,7 @@ describe('processRequest', () => { beforeEach(() => { Bundler.prototype.bundle = jest.fn(() => Promise.resolve({ + getModules: () => [], getSource: () => 'this is the source', getSourceMap: () => {}, getSourceMapString: () => 'this is the source map', @@ -227,6 +228,7 @@ describe('processRequest', () => { bundleFunc .mockReturnValueOnce( Promise.resolve({ + getModules: () => [], getSource: () => 'this is the first source', getSourceMap: () => {}, getSourceMapString: () => 'this is the source map', @@ -235,6 +237,7 @@ describe('processRequest', () => { ) .mockReturnValue( Promise.resolve({ + getModules: () => [], getSource: () => 'this is the rebuilt source', getSourceMap: () => {}, getSourceMapString: () => 'this is the source map', @@ -277,6 +280,7 @@ describe('processRequest', () => { bundleFunc .mockReturnValueOnce( Promise.resolve({ + getModules: () => [], getSource: () => 'this is the first source', getSourceMap: () => {}, getSourceMapString: () => 'this is the source map', @@ -285,6 +289,7 @@ describe('processRequest', () => { ) .mockReturnValue( Promise.resolve({ + getModules: () => [], getSource: () => 'this is the rebuilt source', getSourceMap: () => {}, getSourceMapString: () => 'this is the source map', diff --git a/packages/metro-bundler/src/Server/index.js b/packages/metro-bundler/src/Server/index.js index f3673437..f8e43c69 100644 --- a/packages/metro-bundler/src/Server/index.js +++ b/packages/metro-bundler/src/Server/index.js @@ -309,26 +309,25 @@ class Server { } const opts = bundleOpts(options); - const building = this._bundler.bundle(opts); - building.then(bundle => { - const modules = bundle.getModules(); - const nonVirtual = modules.filter(m => !m.virtual); - bundleDeps.set(bundle, { - files: new Map( - nonVirtual - .map(({sourcePath, meta = {dependencies: []}}) => - [sourcePath, meta.dependencies]) - ), - idToIndex: new Map(modules.map(({id}, i) => [id, i])), - dependencyPairs: new Map( - nonVirtual - .filter(({meta}) => meta && meta.dependencyPairs) - .map(m => [m.sourcePath, m.meta.dependencyPairs]) - ), - outdated: new Set(), - }); + return this._bundler.bundle(opts); + }).then(bundle => { + const modules = bundle.getModules(); + const nonVirtual = modules.filter(m => !m.virtual); + bundleDeps.set(bundle, { + files: new Map( + nonVirtual + .map(({sourcePath, meta = {dependencies: []}}) => + [sourcePath, meta.dependencies]) + ), + idToIndex: new Map(modules.map(({id}, i) => [id, i])), + dependencyPairs: new Map( + nonVirtual + .filter(({meta}) => meta && meta.dependencyPairs) + .map(m => [m.sourcePath, m.meta.dependencyPairs]) + ), + outdated: new Set(), }); - return building; + return bundle; }); }