(ast: Program, importName: string, magicString: MagicString)
| 162 | } |
| 163 | |
| 164 | function 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…