* remove a variable declaration within the code
(codeAst: Program, name: string, magicString: MagicString, removedNodes: WeakSet<Node>)
| 232 | * remove a variable declaration within the code |
| 233 | */ |
| 234 | function removeVariableDeclarator (codeAst: Program, name: string, magicString: MagicString, removedNodes: WeakSet<Node>): Node | void { |
| 235 | // remove variables |
| 236 | walk(codeAst, { |
| 237 | enter (node) { |
| 238 | if (node.type !== 'VariableDeclaration') { return } |
| 239 | for (const declarator of node.declarations) { |
| 240 | const toRemove = findMatchingPatternToRemove(declarator.id, node, name, removedNodes) |
| 241 | if (toRemove) { |
| 242 | magicString.remove(toRemove.start, toRemove.end + 1) |
| 243 | removedNodes.add(toRemove) |
| 244 | } |
| 245 | } |
| 246 | }, |
| 247 | }) |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * find the Pattern to remove which the identifier is equal to the name parameter. |
no outgoing calls
no test coverage detected
searching dependent graphs…