2022-10-06 21:14:21 +08:00
|
|
|
import { sandboxCompileModule } from "../compile.ts";
|
2022-10-05 16:35:01 +08:00
|
|
|
import { SysCallMapping } from "../system.ts";
|
2022-04-26 01:46:08 +08:00
|
|
|
|
2022-06-13 19:06:53 +08:00
|
|
|
// TODO: FIgure out a better way to do this
|
|
|
|
const builtinModules = ["yaml", "handlebars"];
|
2022-05-13 20:36:26 +08:00
|
|
|
|
2022-04-26 01:46:08 +08:00
|
|
|
export function esbuildSyscalls(): SysCallMapping {
|
|
|
|
return {
|
2022-05-13 20:36:26 +08:00
|
|
|
"tsc.analyze": async (
|
|
|
|
ctx,
|
|
|
|
filename: string,
|
2022-10-05 16:35:01 +08:00
|
|
|
code: string,
|
2022-05-13 20:36:26 +08:00
|
|
|
): Promise<any> => {},
|
2022-10-06 21:14:21 +08:00
|
|
|
// "esbuild.compile": async (
|
|
|
|
// ctx,
|
|
|
|
// filename: string,
|
|
|
|
// code: string,
|
|
|
|
// functionName?: string,
|
|
|
|
// excludeModules: string[] = [],
|
|
|
|
// ): Promise<string> => {
|
|
|
|
// return await sandboxCompile(
|
|
|
|
// filename,
|
|
|
|
// code,
|
|
|
|
// functionName,
|
|
|
|
// true,
|
|
|
|
// [],
|
|
|
|
// [...builtinModules, ...excludeModules],
|
|
|
|
// );
|
|
|
|
// },
|
2022-05-13 23:05:52 +08:00
|
|
|
"esbuild.compileModule": async (
|
|
|
|
ctx,
|
2022-10-05 16:35:01 +08:00
|
|
|
moduleName: string,
|
2022-05-13 23:05:52 +08:00
|
|
|
): Promise<string> => {
|
2022-06-13 19:06:53 +08:00
|
|
|
return await sandboxCompileModule(moduleName, builtinModules);
|
2022-04-26 01:46:08 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|