Skip to content

Commit 6315d4e

Browse files
committed
fix: Remove all import declaration.
1 parent fc267bb commit 6315d4e

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/transform.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ export async function BabelTransform(input: string) {
99
return {
1010
name: 'transform-remove-all-import',
1111
visitor: {
12-
// https://babeljs.io/docs/en/babel-types#importspecifier
13-
ImportSpecifier(local: any) {
14-
if (local.parent && local.parent.source && local.parent.source.extra.rawValue) {
15-
if (local.parent.specifiers) {
16-
local.parent.specifiers.forEach((item: any) => {
17-
specifiers.push(item.imported.name);
18-
});
19-
}
20-
local.parentPath.remove();
21-
}
12+
/**
13+
* https://babeljs.io/docs/en/babel-types#importdeclaration
14+
* @param specifiers
15+
* @param source
16+
*/
17+
ImportDeclaration(specifiers: any, source: string) {
18+
specifiers.remove();
2219
},
2320
},
2421
};

0 commit comments

Comments
 (0)