Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip query parameter in File import #16480

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/bun.js/module_loader.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ pub const ModuleLoader = struct {
} else {
// search keywords: "export default \"{}\";"
writer.writeAll("export default ") catch bun.outOfMemory();
buf = js_printer.quoteForJSON(specifier, buf, true) catch bun.outOfMemory();
buf = js_printer.quoteForJSON(path.text, buf, true) catch bun.outOfMemory();
writer = buf.writer();
writer.writeAll(";\n") catch bun.outOfMemory();
}
Expand Down
13 changes: 13 additions & 0 deletions test/regression/issue/16476/16476.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import t1 from "./a.txt?1" with { type: "file" };
import t2 from "./a.txt?2";
import t3 from "./a.txt" with { type: "file" };
import w1 from "./a.wasm?1";
import w2 from "./a.wasm?2";

test("question mark imports", () => {
expect(t1).toEndWith("a.txt");
expect(t2).toBe("hello");
expect(t3).toEndWith("a.txt");
expect(w1).toEndWith("a.wasm");
expect(w2).toEndWith("a.wasm");
});
1 change: 1 addition & 0 deletions test/regression/issue/16476/a.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
Binary file added test/regression/issue/16476/a.wasm
Binary file not shown.
Loading