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
+1 -1
View File
@@ -3,7 +3,7 @@ import standardTypes from "mime/types/standard.js";
import otherTypes from "mime/types/other.js";
const mime = new Mime(standardTypes, otherTypes);
mime.define({ "text/javascript": ["jsx", "tsx"] }, true);
mime.define({ "text/javascript": ["jsx", "tsx", "ts"] }, true);
export const getMimeType = (
ext: string,
+4 -2
View File
@@ -1,12 +1,13 @@
import * as swc from "@swc/core";
export const transformJs = async (code: string) => {
export const transformJs = async (code: string, type: "js" | "ts" = "js") => {
try {
const result = await swc.transform(code, {
jsc: {
parser: {
syntax: type === "js" ? "ecmascript" : "typescript",
jsx: true,
syntax: "ecmascript",
tsx: true,
},
target: "es5",
},
@@ -14,6 +15,7 @@ export const transformJs = async (code: string) => {
return result.code;
} catch (err) {
// console.log(err);
return code;
}
};
+1
View File
@@ -17,6 +17,7 @@ export const unpackProject = async (
) => {
const files = await db.query.file.findMany({
where: and(
eq(file.projectId, projectData.id),
eq(file.isDirectory, false),
eq(file.isFile, false),
isNull(file.deletedAt)