(node, parent)
| 110 | |
| 111 | walk(ast, { |
| 112 | enter(node, parent) { |
| 113 | if (skippedNodes.has(node)) { |
| 114 | this.skip(); |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | if (currentTryBlockEnd !== null && node.start > currentTryBlockEnd) { |
| 119 | currentTryBlockEnd = null; |
| 120 | } |
| 121 | if (currentConditionalNodeEnd !== null && node.start > currentConditionalNodeEnd) { |
| 122 | currentConditionalNodeEnd = null; |
| 123 | } |
| 124 | if (currentConditionalNodeEnd === null && conditionalNodes.has(node)) { |
| 125 | currentConditionalNodeEnd = node.end; |
| 126 | } |
| 127 | |
| 128 | programDepth += 1; |
| 129 | if (node.scope) ({ scope } = node); |
| 130 | if (functionType.test(node.type)) lexicalDepth += 1; |
| 131 | if (sourceMap) { |
| 132 | magicString.addSourcemapLocation(node.start); |
| 133 | magicString.addSourcemapLocation(node.end); |
| 134 | } |
| 135 | |
| 136 | // eslint-disable-next-line default-case |
| 137 | switch (node.type) { |
| 138 | case 'AssignmentExpression': |
| 139 | if (node.left.type === 'MemberExpression') { |
| 140 | const flattened = getKeypath(node.left); |
| 141 | if (!flattened || scope.contains(flattened.name)) return; |
| 142 | |
| 143 | const exportsPatternMatch = exportsPattern.exec(flattened.keypath); |
| 144 | if (!exportsPatternMatch || flattened.keypath === 'exports') return; |
| 145 | |
| 146 | const [, exportName] = exportsPatternMatch; |
| 147 | uses[flattened.name] = true; |
| 148 | |
| 149 | // we're dealing with `module.exports = ...` or `[module.]exports.foo = ...` – |
| 150 | if (flattened.keypath === 'module.exports') { |
| 151 | moduleExportsAssignments.push(node); |
| 152 | if (programDepth > 3) { |
| 153 | moduleAccessScopes.add(scope); |
| 154 | } else if (!firstTopLevelModuleExportsAssignment) { |
| 155 | firstTopLevelModuleExportsAssignment = node; |
| 156 | } |
| 157 | } else if (exportName === KEY_COMPILED_ESM) { |
| 158 | if (programDepth > 3) { |
| 159 | shouldWrap = true; |
| 160 | } else { |
| 161 | // The "type" is either "module" or "exports" to discern |
| 162 | // assignments to module.exports vs exports if needed |
| 163 | topLevelDefineCompiledEsmExpressions.push({ node, type: flattened.name }); |
| 164 | } |
| 165 | } else { |
| 166 | const exportsAssignments = exportsAssignmentsByName.get(exportName) || { |
| 167 | nodes: [], |
| 168 | scopes: new Set() |
| 169 | }; |
nothing calls this directly
no test coverage detected