diff options
author | 2022-09-05 23:05:22 -0700 | |
---|---|---|
committer | 2022-09-05 23:05:22 -0700 | |
commit | 11aa17a57cc679d34e8e6f6f7aa665f565cb7305 (patch) | |
tree | ccb9a605cb4bcc42c6b2665ddbf8d04af72d94c7 /test/bun.js/bun-loader-svelte/bun-loader-svelte.ts | |
parent | d2397b60e79e4386c6a7b7a9783a6f8e379a5ae0 (diff) | |
download | bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.gz bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.tar.zst bun-11aa17a57cc679d34e8e6f6f7aa665f565cb7305.zip |
Support async `onLoad` callbacks in `Bun.plugin`
Diffstat (limited to 'test/bun.js/bun-loader-svelte/bun-loader-svelte.ts')
-rw-r--r-- | test/bun.js/bun-loader-svelte/bun-loader-svelte.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/bun.js/bun-loader-svelte/bun-loader-svelte.ts b/test/bun.js/bun-loader-svelte/bun-loader-svelte.ts new file mode 100644 index 000000000..f0a6e3419 --- /dev/null +++ b/test/bun.js/bun-loader-svelte/bun-loader-svelte.ts @@ -0,0 +1,18 @@ +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, "utf8"), { + filename: path, + generate: "ssr", + }).js.code, + loader: "js", + })); + await 1; + }, +}); |