Skip to content

Commit

Permalink
Call shouldGenerateSourceMap only once (#4104)
Browse files Browse the repository at this point in the history
## Summary

This PR stores the result of `shouldGenerateSourceMap` to avoid calling
it twice.

## Test plan

Trust me bro
  • Loading branch information
tomekzaw authored Feb 24, 2023
1 parent 84ef868 commit 43a9063
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -216,8 +218,6 @@ function buildWorkletString(t, fun, closureVariables, name, inputMap) {
}
}

const includeSourceMap = shouldGenerateSourceMap();

const transformed = transformSync(code, {
plugins: [prependClosureVariablesIfNecessary()],
compact: !includeSourceMap,
Expand Down

0 comments on commit 43a9063

Please sign in to comment.