Skip to content

Commit 9a9738d

Browse files
committed
fix(transformation): Leave imports which have no specifiers unchanged
canReplace was returning true and the path was then replaced by an empty array, which made the import disappear.
1 parent c074fc6 commit 9a9738d

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

source/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default function ({types: t}) {
2-
const canReplace = (node) => {
3-
return node.specifiers.every((specifier) => {
2+
const canReplace = ({ specifiers }) => {
3+
return specifiers.length > 0 && specifiers.every((specifier) => {
44
return t.isImportSpecifier(specifier)
55
&& specifier.imported.name !== 'default';
66
});

test/fixtures/no-specifier/actual.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'react-router';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'react-router';

0 commit comments

Comments
 (0)