MCPcopy
hub / github.com/nuxt/nuxt / removeVariableDeclarator

Function removeVariableDeclarator

packages/nuxt/src/components/plugins/tree-shake.ts:234–248  ·  view source on GitHub ↗

* remove a variable declaration within the code

(codeAst: Program, name: string, magicString: MagicString, removedNodes: WeakSet<Node>)

Source from the content-addressed store, hash-verified

232 * remove a variable declaration within the code
233 */
234function 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.

Callers 1

handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…