MCPcopy
hub / github.com/nuxt/nuxt / removeImportDeclaration

Function removeImportDeclaration

packages/nuxt/src/components/plugins/tree-shake.ts:164–182  ·  view source on GitHub ↗
(ast: Program, importName: string, magicString: MagicString)

Source from the content-addressed store, hash-verified

162}
163
164function removeImportDeclaration (ast: Program, importName: string, magicString: MagicString): boolean {
165 for (const node of ast.body) {
166 if (node.type !== 'ImportDeclaration' || !node.specifiers) {
167 continue
168 }
169 const specifierIndex = node.specifiers.findIndex(s => s.local.name === importName)
170 if (specifierIndex > -1) {
171 if (node.specifiers!.length > 1) {
172 const specifier = node.specifiers![specifierIndex]!
173 magicString.remove(specifier.start, specifier.end + 1)
174 node.specifiers!.splice(specifierIndex, 1)
175 } else {
176 magicString.remove(node.start, node.end)
177 }
178 return true
179 }
180 }
181 return false
182}
183
184/**
185 * detect if the component is called else where

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…