diff --git a/packager/react-packager/src/JSTransformer/index.js b/packager/react-packager/src/JSTransformer/index.js index 712489db2..54e2d8e0f 100644 --- a/packager/react-packager/src/JSTransformer/index.js +++ b/packager/react-packager/src/JSTransformer/index.js @@ -115,10 +115,11 @@ class Transformer { debug('transforming file', fileName); return this ._transform(this._transformModulePath, fileName, code, options, transformCacheKey) - .then(stats => { - Logger.log(stats.transformFileStartLogEntry); - Logger.log(stats.transformFileEndLogEntry); + .then(data => { + Logger.log(data.transformFileStartLogEntry); + Logger.log(data.transformFileEndLogEntry); debug('done transforming file', fileName); + return data.result; }) .catch(error => { if (error.type === 'TimeoutError') { diff --git a/packager/react-packager/src/JSTransformer/worker/index.js b/packager/react-packager/src/JSTransformer/worker/index.js index 7b9cb8ab0..e64253282 100644 --- a/packager/react-packager/src/JSTransformer/worker/index.js +++ b/packager/react-packager/src/JSTransformer/worker/index.js @@ -87,6 +87,7 @@ function transformCode(transform, filename, sourceCode, options, transformCacheK result, }); return callback(null, { + result, transformFileStartLogEntry, transformFileEndLogEntry, }); diff --git a/packager/react-packager/src/node-haste/Module.js b/packager/react-packager/src/node-haste/Module.js index 7870ef651..427b57b39 100644 --- a/packager/react-packager/src/node-haste/Module.js +++ b/packager/react-packager/src/node-haste/Module.js @@ -242,27 +242,9 @@ class Module { return callback(null, {code: sourceCode}); } const codePromise = transformCode(this, sourceCode, transformOptions); - return codePromise.then(() => { - const transformCacheKey = this._transformCacheKey; - invariant(transformCacheKey != null, 'missing transform cache key'); - const freshResult = - TransformCache.readSync({ - filePath: this.path, - sourceCode, - transformCacheKey, - transformOptions, - cacheOptions: this._options, - }); - if (freshResult == null) { - callback(new Error( - 'Could not read fresh result from transform cache. This ' + - 'means there is probably a bug in the worker code ' + - 'that prevents it from writing to the cache correctly.', - )); - return; - } + return codePromise.then(freshResult => { callback(undefined, freshResult); - }, callback); + }); }, callback); } diff --git a/packager/react-packager/src/node-haste/__tests__/Module-test.js b/packager/react-packager/src/node-haste/__tests__/Module-test.js index 813a64dbd..4f57ed7b9 100644 --- a/packager/react-packager/src/node-haste/__tests__/Module-test.js +++ b/packager/react-packager/src/node-haste/__tests__/Module-test.js @@ -285,7 +285,7 @@ describe('Module', () => { transformCacheKey, result: transformResult, }); - return Promise.resolve(); + return Promise.resolve(transformResult); }); mockIndexFile(fileContents); });