-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathtransformer.js
More file actions
21 lines (19 loc) · 654 Bytes
/
transformer.js
File metadata and controls
21 lines (19 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Remove perf timing statements from build
module.exports = function (program, cfg, { ts }) {
return (ctx) => {
return function visit(node) {
if (!cfg.removePerf) return node;
// Remove the functions
if (ts.isFunctionDeclaration(node)
&& [ 'perfStart', 'perfStop' ].includes(node.name.escapedText))
return undefined
// Remove the invokes
if (
ts.isExpressionStatement(node) && ts.isCallExpression(node.expression) &&
[ 'perfStart', 'perfStop' ].includes(node.expression.expression.text)
)
return undefined;
return ts.visitEachChild(node, visit, ctx);
}
}
}