mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 22:32:06 +00:00
23 lines
578 B
TypeScript
23 lines
578 B
TypeScript
import { plugin } from "bun";
|
|
|
|
await plugin({
|
|
name: "svelte loader",
|
|
async setup(builder) {
|
|
var { compile } = await import("svelte/compiler");
|
|
var { readFileSync } = await import("fs");
|
|
await 2;
|
|
builder.onLoad({ filter: /\.svelte(\?[^.]+)?$/ }, ({ path }) => ({
|
|
contents: compile(
|
|
readFileSync(path.substring(0, path.includes("?") ? path.indexOf("?") : path.length), "utf-8"),
|
|
{
|
|
filename: path,
|
|
generate: "server",
|
|
dev: false,
|
|
},
|
|
).js.code,
|
|
loader: "js",
|
|
}));
|
|
await 1;
|
|
},
|
|
});
|