fix(Bun.plugin): return on invalid target error (#24945)

### What does this PR do?

### How did you verify your code works?

Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
Dylan Conway
2025-11-23 01:41:42 -08:00
committed by GitHub
parent 7076fbbe68
commit 29051f9340
2 changed files with 12 additions and 0 deletions

View File

@@ -355,6 +355,17 @@ describe("errors", () => {
}
});
it("handles invalid 'target'", () => {
const opts = {
setup: () => {},
target: 123n,
};
expect(() => {
plugin(opts as any);
}).toThrow("plugin target must be one of 'node', 'bun' or 'browser'");
});
it("invalid loaders throw", () => {
const invalidLoaders = ["blah", "blah2", "blah3", "blah4"];
const inputs = ["body { background: red; }", "<h1>hi</h1>", '{"hi": "there"}', "hi"];