( node: Node, module: SourceModule, seen: Set<Node> )
| 3438 | isRunAtLoadBy(node, module, new Set()) |
| 3439 | |
| 3440 | const isRunAtLoadBy = ( |
| 3441 | node: Node, |
| 3442 | module: SourceModule, |
| 3443 | seen: Set<Node> |
| 3444 | ): boolean => { |
| 3445 | for ( |
| 3446 | let child = node, parent = node.parent; |
| 3447 | parent; |
| 3448 | child = parent, parent = parent.parent |
| 3449 | ) { |
| 3450 | if ( |
| 3451 | (parent.type === "PropertyDefinition" || |
| 3452 | parent.type === "AccessorProperty") && |
| 3453 | parent.value === child && |
| 3454 | !parent.static |
| 3455 | ) |
| 3456 | return isUsedAtLoad(parent.parent!.parent!, "NewExpression", module, seen) |
| 3457 | if (!isFunctionNode(parent)) continue |
| 3458 | // a generator's body runs once it's iterated, and an async one's past an |
| 3459 | // await once every module has loaded |
| 3460 | if (parent.async || parent.generator) return false |
| 3461 | const [operand, operator] = operatorOf(parent) |
| 3462 | // e.g. `(() => type(...))()` |
| 3463 | if (operator?.type === "CallExpression" && operator.callee === operand) |
| 3464 | return isRunAtLoadBy(operator, module, seen) |
| 3465 | if (parent.parent?.type === "MethodDefinition") { |
| 3466 | return ( |
| 3467 | parent.parent.kind === "constructor" && |
| 3468 | isUsedAtLoad( |
| 3469 | parent.parent.parent!.parent!, |
| 3470 | "NewExpression", |
| 3471 | module, |
| 3472 | seen |
| 3473 | ) |
| 3474 | ) |
| 3475 | } |
| 3476 | return isUsedAtLoad(parent, "CallExpression", module, seen) |
| 3477 | } |
| 3478 | return true |
| 3479 | } |
| 3480 | |
| 3481 | // whether its module calls a function or constructs a class as it loads |
| 3482 | const isUsedAtLoad = ( |
no test coverage detected