Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/metal-ligers-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bob-the-bundler": patch
---

Support type imports/exports.
6 changes: 6 additions & 0 deletions src/utils/rewrite-code-imports.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ it("ignores module import statement", () => {
expect(result).toEqual("import foo from 'foo';");
});

it("handles type statements", () => {
const fixture = "import type foo from 'foo'";
const result = rewriteCodeImports(fixture, fixturePath);
expect(result).toEqual("import type foo from 'foo';");
});

it("rewrites relative import statement", () => {
const fixture = "import foo from './bar'";
const result = rewriteCodeImports(fixture, fixturePath);
Expand Down
1 change: 1 addition & 0 deletions src/utils/rewrite-code-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function rewriteCodeImports(
): string {
const ast = parse(fileContents, {
sourceType: "module",
plugins: ["typescript"],
});

const relativeDirname = path.dirname(absoluteFilePath);
Expand Down