Lazily access source all the way up

Reviewed By: jeanlauliac

Differential Revision: D7602299

fbshipit-source-id: e3787d164a691350cb37183b4738947902cc85cf
This commit is contained in:
Miguel Jimenez Esun 2018-04-12 14:36:12 -07:00 committed by Facebook Github Bot
parent 55e7e50232
commit b278e42155
1 changed files with 9 additions and 1 deletions

View File

@ -232,7 +232,15 @@ async function processEdge(
// Update the edge information. // Update the edge information.
edge.output.code = result.code; edge.output.code = result.code;
edge.output.map = result.map; edge.output.map = result.map;
edge.output.source = result.source; // TODO(T28259615): Remove as soon as possible to avoid leaking.
// Lazily access source code; if not needed, don't read the file.
// eslint-disable-next-line lint/flow-no-fixme
// $FlowFixMe: "defineProperty" with a getter is buggy in flow.
Object.defineProperty(edge.output, 'source', {
configurable: true,
enumerable: true,
get: () => result.source,
});
edge.dependencies = new Map(); edge.dependencies = new Map();
currentDependencies.forEach((absolutePath, relativePath) => { currentDependencies.forEach((absolutePath, relativePath) => {