We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 66b5300 commit 24de60fCopy full SHA for 24de60f
src/utils/removeImports.ts
@@ -1,3 +1,6 @@
1
export default function removeImports(code: string) {
2
- return code.replace(/^import\s.+\sfrom\s.+;?$/gm, "").trim();
+ 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();
6
}
0 commit comments