Skip to content

Commit 0c36290

Browse files
authored
fix: support type import/exports (#103)
1 parent 7883b57 commit 0c36290

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

.changeset/metal-ligers-occur.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"bob-the-bundler": patch
3+
---
4+
5+
Support type imports/exports.

src/utils/rewrite-code-imports.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ it("ignores module import statement", () => {
99
expect(result).toEqual("import foo from 'foo';");
1010
});
1111

12+
it("handles type statements", () => {
13+
const fixture = "import type foo from 'foo'";
14+
const result = rewriteCodeImports(fixture, fixturePath);
15+
expect(result).toEqual("import type foo from 'foo';");
16+
});
17+
1218
it("rewrites relative import statement", () => {
1319
const fixture = "import foo from './bar'";
1420
const result = rewriteCodeImports(fixture, fixturePath);

src/utils/rewrite-code-imports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function rewriteCodeImports(
3333
): string {
3434
const ast = parse(fileContents, {
3535
sourceType: "module",
36+
plugins: ["typescript"],
3637
});
3738

3839
const relativeDirname = path.dirname(absoluteFilePath);

0 commit comments

Comments
 (0)