Skip to content

Commit 2ac95da

Browse files
filipesilvahansl
authored andcommitted
docs(@angular-devkit/build-optimizer): clarify prefix-functions comment
1 parent dec625f commit 2ac95da

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/angular_devkit/build_optimizer/src/transforms/prefix-functions.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ export function findTopLevelFunctions(parentNode: ts.Node): Set<ts.Node> {
5353
const topLevelFunctions = new Set<ts.Node>();
5454

5555
function cb(node: ts.Node) {
56-
// Stop recursing into this branch if it's a function expression or declaration, a class, or
57-
// a arrow function (lambda).
56+
// Stop recursing into this branch if it's a definition construct.
57+
// These are function expression, function declaration, class, or arrow function (lambda).
58+
// The body of these constructs will not execute when loading the module, so we don't
59+
// need to mark function calls inside them as pure.
60+
// Class static initializers in ES2015 are an exception we don't cover. They would need similar
61+
// processing as enums to prevent property setting from causing the class to be retained.
5862
if (ts.isFunctionDeclaration(node)
5963
|| ts.isFunctionExpression(node)
6064
|| ts.isClassDeclaration(node)

0 commit comments

Comments
 (0)