Skip to content

Commit

Permalink
ignore babel macro imports (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed May 31, 2020
1 parent 04280df commit 65d9715
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/scan-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ function parseCodeForInstallTargets(fileLoc: string, code: string): InstallTarge
}
const allImports: InstallTarget[] = imports
.map((imp) => parseImportStatement(code, imp))
.filter(isTruthy);
.filter(isTruthy)
// Babel macros are not install targets!
.filter((imp) => !imp.specifier.endsWith('.macro'));
return allImports;
}

Expand Down
1 change: 1 addition & 0 deletions test/integration/include/dir/f.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ function g() {
class C {
@f()
@g()
// @ts-ignore
method() {}
}
4 changes: 4 additions & 0 deletions test/integration/include/dir/g.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// test 7: Ignore babel macros
import 'twin.macro';
// @ts-ignore
import preval from 'preval.macro';

0 comments on commit 65d9715

Please sign in to comment.