From 43a9063f893951b0b43bcfc3ff9ed782f8ce5583 Mon Sep 17 00:00:00 2001 From: Tomek Zawadzki Date: Fri, 24 Feb 2023 21:51:18 +0100 Subject: [PATCH] Call `shouldGenerateSourceMap` only once (#4104) ## Summary This PR stores the result of `shouldGenerateSourceMap` to avoid calling it twice. ## Test plan Trust me bro --- plugin/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/index.js b/plugin/index.js index 504dc7a76f5..c3a928c3ace 100644 --- a/plugin/index.js +++ b/plugin/index.js @@ -204,7 +204,9 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) { const code = generate(workletFunction).code; - if (shouldGenerateSourceMap()) { + const includeSourceMap = shouldGenerateSourceMap(); + + if (includeSourceMap) { // Clear contents array (should be empty anyways) inputMap.sourcesContent = []; // Include source contents in source map, because Flipper/iframe is not @@ -216,8 +218,6 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) { } } - const includeSourceMap = shouldGenerateSourceMap(); - const transformed = transformSync(code, { plugins: [prependClosureVariablesIfNecessary()], compact: !includeSourceMap,