mirror of
https://github.com/khairul169/code-share.git
synced 2026-10-24 11:53:58 +07:00
fix: typescript support fix, add some params to editor, etc
This commit is contained in:
+2
-1
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user