Skip to content

Commit

Permalink
still does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbloxhub committed Oct 19, 2024
1 parent bea1b51 commit 125a04c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
Binary file modified bun.lockb
Binary file not shown.
40 changes: 40 additions & 0 deletions bun_setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { GlobalRegistrator } from "@happy-dom/global-registrator"
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"
import { plugin } from "bun"
import { afterEach, expect } from "bun:test"
import { cleanup } from "@testing-library/svelte"
import * as matchers from "@testing-library/jest-dom/matchers"

expect.extend(matchers)

afterEach(() => {
cleanup()
})

const oldConsole = console
GlobalRegistrator.register()
window.console = oldConsole

await plugin({
name: "svelte loader",
async setup(builder) {
const { compile, preprocess } = await import("svelte/compiler")
const { readFileSync } = await import("fs")

builder.onLoad({ filter: /\.svelte$/ }, async ({ path }) => {
return {
// Use the preprocessor of your choice.
contents: compile(
await preprocess(readFileSync(path, "utf8"), vitePreprocess()).then(
(processed) => processed.code,
),
{
filename: path,
generate: "client",
},
).js.code,
loader: "js",
}
})
},
})
2 changes: 1 addition & 1 deletion bunfig.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[test]
preload = ["./happydom.ts", "./testing-library.ts", "./bun-svelte.ts"]
preload = ["./bun_setup.ts"]
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"@sveltejs/kit": "^2.7.1",
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.1",
"@testing-library/svelte": "^5.2.3",
"@testing-library/jest-dom": "^6.6.2",
"@testing-library/svelte": "^5.2.4",
"@types/bun": "^1.1.11",
"@types/eslint": "^9.6.1",
"concurrently": "^9.0.1",
"eslint": "^9.12.0",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.45.1",
"globals": "^15.11.0",
Expand All @@ -24,7 +24,7 @@
"svelte-check": "^4.0.5",
"tslib": "^2.8.0",
"typescript": "^5.6.3",
"typescript-eslint": "^8.9.0",
"typescript-eslint": "^8.10.0",
"vite": "^5.4.9"
},
"type": "module"
Expand Down

0 comments on commit 125a04c

Please sign in to comment.