diff --git a/.vscode/launch.json b/.vscode/launch.json
index 0924c20673..cd232a98a4 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1131,6 +1131,17 @@
// Don't pause when the GC runs while the debugger is open.
"postRunCommands": ["command source '${workspaceFolder}/misctools/lldb/lldb_commands'"],
},
+ {
+ "type": "bun",
+ "name": "[JS] bun test [file]",
+ "runtime": "${workspaceFolder}/build/debug/bun-debug",
+ "runtimeArgs": ["test", "${file}"],
+ "cwd": "${workspaceFolder}",
+ "env": {
+ "BUN_DEBUG_QUIET_LOGS": "1",
+ "BUN_GARBAGE_COLLECTOR_LEVEL": "2",
+ },
+ },
{
"type": "midas-rr",
"request": "attach",
diff --git a/packages/bun-plugin-svelte/README.md b/packages/bun-plugin-svelte/README.md
index 9a29a903e1..b599c9ecb0 100644
--- a/packages/bun-plugin-svelte/README.md
+++ b/packages/bun-plugin-svelte/README.md
@@ -84,3 +84,13 @@ Bun.build({
`bun-plugin-svelte` does not yet support server-side imports (e.g. for SSR).
This will be added in the near future.
+
+## Not Yet Supported
+
+Support for these features will be added in the near future
+
+- Server-side imports/rendering
+- Source maps
+- CSS extensions (e.g. tailwind) in `
diff --git a/packages/bun-plugin-svelte/test/fixtures/with-modules.svelte b/packages/bun-plugin-svelte/test/fixtures/with-modules.svelte
new file mode 100644
index 0000000000..39421203ef
--- /dev/null
+++ b/packages/bun-plugin-svelte/test/fixtures/with-modules.svelte
@@ -0,0 +1,25 @@
+
+
+
+ Hello {todo.title}!
+
+
+
+
+
+
diff --git a/packages/bun-plugin-svelte/test/index.test.ts b/packages/bun-plugin-svelte/test/index.test.ts
index 63e1bddcfd..48c97a7311 100644
--- a/packages/bun-plugin-svelte/test/index.test.ts
+++ b/packages/bun-plugin-svelte/test/index.test.ts
@@ -4,6 +4,7 @@ import fs from "node:fs";
import os from "node:os";
import { render } from "svelte/server";
import { SveltePlugin } from "../src";
+import type { BuildOutput } from "bun";
const fixturePath = (...segs: string[]) => path.join(import.meta.dirname, "fixtures", ...segs);
@@ -32,6 +33,46 @@ it("hello world component", async () => {
expect(res.success).toBeTrue();
});
+describe("when importing `.svelte.ts` files with ESM", () => {
+ let res: BuildOutput;
+
+ beforeAll(async () => {
+ res = await Bun.build({
+ entrypoints: [fixturePath("with-modules.svelte")],
+ outdir,
+ plugins: [SveltePlugin()],
+ });
+ });
+
+ it("builds successfully", () => {
+ expect(res.success).toBeTrue();
+ });
+});
+
+describe("when importing `.svelte.ts` files with CJS", () => {
+ let res: BuildOutput;
+
+ beforeAll(async () => {
+ res = await Bun.build({
+ entrypoints: [fixturePath("with-cjs.svelte")],
+ outdir,
+ plugins: [SveltePlugin()],
+ });
+ });
+
+ it("builds successfully", () => {
+ expect(res.success).toBeTrue();
+ });
+
+ it("does not double-wrap the module with function(module, exports, __filename, __dirname)", async () => {
+ const ts = res.outputs.find(output => output.loader === "ts");
+ expect(ts).toBeDefined();
+ const code = await ts!.text();
+ expect(code).toContain("require_todo_cjs_svelte");
+ expect(code).toContain("var require_todo_cjs_svelte = __commonJS((exports, module) => {\n");
+ });
+});
+
describe("Bun.build", () => {
it.each(["node", "bun"] as const)('Generates server-side code when targeting "node" or "bun"', async target => {
const res = await Bun.build({