From 1c3adf5d211ce5c80b68d56e0ac7a43ae01a0d61 Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Tue, 10 Apr 2018 21:42:50 -0700 Subject: [PATCH] Fix source map generation with experimental caches Summary: Fixes a typo with a property name that flow did not catch. Reviewed By: mjesun Differential Revision: D7582300 fbshipit-source-id: 039550dffb0f22ed8d2820e7fdcbe35c1d012c68 --- packages/metro/src/node-haste/Module.js | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/metro/src/node-haste/Module.js b/packages/metro/src/node-haste/Module.js index 4bf4db40..dac5a077 100644 --- a/packages/metro/src/node-haste/Module.js +++ b/packages/metro/src/node-haste/Module.js @@ -304,18 +304,22 @@ class Module { // TODO: T26134860 Cache layer lives inside the transformer now; just call // the transform method. if (this._experimentalCaches) { - // Source code is read on the worker. - const data = { - ...(await this._transformCode(this, null, transformOptions)), + const result: TransformedCode = await this._transformCode( + this, + null, // Source code is read on the worker + transformOptions, + ); + + const module = this; + + return { + code: result.code, + dependencies: result.dependencies, + map: result.map, + get source() { + return module._readSourceCode(); + }, }; - - // eslint-disable-next-line lint/flow-no-fixme - // $FlowFixMe: Flow wants "value" here, where the get is for AVOIDING it. - Object.defineProperty(data, 'sourceCode', { - get: () => this._readSourceCode.bind(this), - }); - - return data; } const cached = this.readCached(transformOptions);