Skip to content

Commit

Permalink
delete buggy jsx
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Nov 20, 2024
1 parent 2c53bf0 commit 7c3c341
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 59 deletions.
48 changes: 0 additions & 48 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@ import {
import { contentType } from "https://deno.land/[email protected]/media_types/content_type.ts"
import { transpile } from "./src/transpile.ts"

import {
relative,
join,
normalize,
fromFileUrl,
} from "https://deno.land/[email protected]/path/mod.ts"

const cwd = Deno.cwd()
const scriptDir = join(fromFileUrl(import.meta.url), "..")
console.log({cwd, scriptDir})
const relPath = normalize(relative(scriptDir, cwd))

const relImport = async (path: string) => {
const adjustedPath = join(relPath, path).replaceAll("\\", "/")

return await import("./" + adjustedPath)
}

const getFile = async (filepath: string) =>
await Deno.open(
filepath,
Expand Down Expand Up @@ -84,38 +66,8 @@ async (filepath: string, url: URL) => {
}
}

const htmlPreset =
(body: string) => `<!doctype html><html>
<head>
<meta charset="UTF-8">
</head>
<body>
${body}
</body>
</html>`

let cacheBuster = 0

Deno.serve(handler({
ts: handleTs,
async tsx(filepath, url, req) {
const accept = req.headers.get("accept") || ""

if (accept.includes("text/html")) {
return new Response(
htmlPreset(
(await relImport(
filepath + "#" + cacheBuster++
)).default
),
{ headers: {
"content-type": "text/html",
}}
)
} else {
return await handleTs(filepath, url)
}
}
}))

const appendParam =
Expand Down
6 changes: 0 additions & 6 deletions test/tsx/deno.json

This file was deleted.

5 changes: 0 additions & 5 deletions test/tsx/index.tsx

This file was deleted.

0 comments on commit 7c3c341

Please sign in to comment.