Skip to content

Commit 7872467

Browse files
authored
Merge pull request #69 from kellyselden/remove_blank
remove imports without specifiers
2 parents e23b7b3 + 2cf1c63 commit 7872467

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

fixtures/removes-imports-without-specifiers/expectation6.js

Whitespace-only changes.

fixtures/removes-imports-without-specifiers/expectation7.js

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@ember/debug-tools';
2+
import '@glimmer/env';

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ function macros(babel) {
8383
let debugToolsImport = options.debugTools.debugToolsImport;
8484

8585
if (debugToolsImport && debugToolsImport === importPath) {
86-
this.macroBuilder.collectDebugToolsSpecifiers(item.get('specifiers'));
86+
if (!item.node.specifiers.length) {
87+
item.remove();
88+
} else {
89+
this.macroBuilder.collectDebugToolsSpecifiers(item.get('specifiers'));
90+
}
8791
}
8892
}
8993
});

tests/create-tests.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,26 @@ function createTests(options) {
327327
h.generateTest('does-not-modify-non-imported-flags');
328328
});
329329

330+
describe('Removes Imports Without Specifiers', function() {
331+
let h = transformTestHelper({
332+
presets,
333+
plugins: [
334+
[
335+
DebugToolsPlugin,
336+
{
337+
debugTools: {
338+
isDebug: true,
339+
source: '@ember/debug-tools',
340+
},
341+
flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }],
342+
},
343+
],
344+
],
345+
});
346+
347+
h.generateTest('removes-imports-without-specifiers');
348+
});
349+
330350
describe('Runtime Feature Flags', function() {
331351
let h = transformTestHelper({
332352
presets,

0 commit comments

Comments
 (0)