1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export async function prettifyTS(code: string) {
const prettier = await import(
"https://unpkg.com/prettier@3.0.1/standalone.mjs"
);
const prettierPluginTypescript = await import(
"https://unpkg.com/prettier@3.0.1/plugins/typescript.mjs"
);
const prettierPluginEstree = await import(
"https://unpkg.com/prettier@3.0.1/plugins/estree.mjs"
);
return prettier.format(code, {
parser: "typescript",
plugins: [prettierPluginTypescript, prettierPluginEstree],
});
}