fix: typescript support fix, add some params to editor, etc

This commit is contained in:
2024-02-28 22:32:31 +00:00
parent 7bdd995394
commit 543260479a
16 changed files with 136 additions and 34 deletions
+2 -1
View File
@@ -3,11 +3,12 @@ import preview from "./preview";
import trpc from "./trpc/handler";
import { thumbnail } from "./thumbnail";
import sandbox from "./sandbox";
import { nocache } from "../middlewares/nocache";
const api = Router();
api.use("/trpc", trpc);
api.use("/preview", preview);
api.use("/preview", nocache, preview);
api.use("/sandbox", sandbox);
api.get("/thumbnail/:slug", thumbnail);
+4 -1
View File
@@ -1,3 +1,4 @@
import { getFileExt } from "~/lib/utils";
import { FileSchema } from "~/server/db/schema/file";
import { ProjectSettingsSchema } from "~/server/db/schema/project";
import { transformJs } from "~/server/lib/transform-js";
@@ -10,7 +11,9 @@ export const serveJs = async (
// transpile to es5
if (cfg?.transpiler === "swc") {
content = await transformJs(content);
const ext = getFileExt(file.filename);
const typescript = ["ts", "tsx"].includes(ext);
content = await transformJs(content, typescript ? "ts" : "js");
}
return content;