Skip to content

Commit 24de60f

Browse files
committed
fix: unremoved multiline named import issue
1 parent 66b5300 commit 24de60f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/removeImports.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
export default function removeImports(code: string) {
2-
return code.replace(/^import\s.+\sfrom\s.+;?$/gm, "").trim();
2+
return code
3+
.replace(/(^import\s+[^;]+;?$|^import\s+[^;]*\sfrom\s.+;?$)/gm, "") // matches single-line imports and side-effect imports
4+
.replace(/(^import\s+{[\s\S]+?}\s+from\s+["'][^"']+["'];?)/gm, "") // matches multiline named imports
5+
.trim();
36
}

0 commit comments

Comments
 (0)