diff --git a/react-packager/src/Server/__tests__/Server-test.js b/react-packager/src/Server/__tests__/Server-test.js index a2248842..796f281a 100644 --- a/react-packager/src/Server/__tests__/Server-test.js +++ b/react-packager/src/Server/__tests__/Server-test.js @@ -197,7 +197,7 @@ describe('processRequest', () => { }); }); - it('rebuilds the bundles that contain a file when that file is changed', () => { + it('does not rebuild the bundles that contain a file when that file is changed', () => { const bundleFunc = jest.genMockFunction(); bundleFunc .mockReturnValueOnce( @@ -233,7 +233,7 @@ describe('processRequest', () => { jest.runAllTimers(); jest.runAllTicks(); - expect(bundleFunc.mock.calls.length).toBe(2); + expect(bundleFunc.mock.calls.length).toBe(1); makeRequest(requestHandler, 'mybundle.bundle?runModule=true') .done(response => @@ -242,7 +242,7 @@ describe('processRequest', () => { jest.runAllTicks(); }); - it('rebuilds the bundles that contain a file when that file is changed, even when hot loading is enabled', () => { + it('does not rebuild the bundles that contain a file when that file is changed, even when hot loading is enabled', () => { const bundleFunc = jest.genMockFunction(); bundleFunc .mockReturnValueOnce( diff --git a/react-packager/src/Server/index.js b/react-packager/src/Server/index.js index c1f20606..985516be 100644 --- a/react-packager/src/Server/index.js +++ b/react-packager/src/Server/index.js @@ -197,7 +197,7 @@ class Server { this._fileWatcher.on('all', this._onFileChange.bind(this)); this._debouncedFileChangeHandler = _.debounce(filePath => { - this._rebuildBundles(filePath); + this._clearBundles(); this._informChangeWatchers(); }, 50); } @@ -293,30 +293,6 @@ class Server { this._bundles = Object.create(null); } - _rebuildBundles() { - const buildBundle = this.buildBundle.bind(this); - const bundles = this._bundles; - - Object.keys(bundles).forEach(function(optionsJson) { - const options = JSON.parse(optionsJson); - // Wait for a previous build (if exists) to finish. - bundles[optionsJson] = (bundles[optionsJson] || Promise.resolve()).finally(function() { - // With finally promise callback we can't change the state of the promise - // so we need to reassign the promise. - bundles[optionsJson] = buildBundle(options).then(function(p) { - // Make a throwaway call to getSource to cache the source string. - p.getSource({ - inlineSourceMap: options.inlineSourceMap, - minify: options.minify, - dev: options.dev, - }); - return p; - }); - }); - return bundles[optionsJson]; - }); - } - _informChangeWatchers() { const watchers = this._changeWatchers; const headers = {