fix(cli): ignore import types when analyzing deps (#8574)

This commit is contained in:
neverland 2021-04-19 19:13:09 +08:00 committed by GitHub
parent 84b45c4840
commit 33bdcbc029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,8 @@ let existsCache: Record<string, boolean> = {};
const IMPORT_RE = /import\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g; const IMPORT_RE = /import\s+?(?:(?:(?:[\w*\s{},]*)\s+from(\s+)?)|)(?:(?:".*?")|(?:'.*?'))[\s]*?(?:;|$|)/g;
function matchImports(code: string): string[] { function matchImports(code: string): string[] {
return code.match(IMPORT_RE) || []; const imports = code.match(IMPORT_RE) || [];
return imports.filter((line) => !line.includes('import type'));
} }
function exists(filePath: string) { function exists(filePath: string) {