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:
+1
-1
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user