2022-05-13 15:05:52 +00:00
|
|
|
import { sandboxCompile, sandboxCompileModule } from "../compile";
|
2022-04-25 17:46:08 +00:00
|
|
|
import { SysCallMapping } from "../system";
|
|
|
|
|
2022-06-13 11:06:53 +00:00
|
|
|
// TODO: FIgure out a better way to do this
|
|
|
|
const builtinModules = ["yaml", "handlebars"];
|
2022-05-13 12:36:26 +00:00
|
|
|
|
2022-04-25 17:46:08 +00:00
|
|
|
export function esbuildSyscalls(): SysCallMapping {
|
|
|
|
return {
|
2022-05-13 12:36:26 +00:00
|
|
|
"tsc.analyze": async (
|
|
|
|
ctx,
|
|
|
|
filename: string,
|
|
|
|
code: string
|
|
|
|
): Promise<any> => {},
|
2022-04-25 17:46:08 +00:00
|
|
|
"esbuild.compile": async (
|
|
|
|
ctx,
|
|
|
|
filename: string,
|
2022-05-11 09:49:27 +00:00
|
|
|
code: string,
|
2022-05-13 15:05:52 +00:00
|
|
|
functionName?: string,
|
|
|
|
excludeModules: string[] = []
|
2022-04-25 17:46:08 +00:00
|
|
|
): Promise<string> => {
|
2022-05-13 15:05:52 +00:00
|
|
|
return await sandboxCompile(
|
|
|
|
filename,
|
|
|
|
code,
|
|
|
|
functionName,
|
|
|
|
true,
|
|
|
|
[],
|
2022-06-13 11:06:53 +00:00
|
|
|
[...builtinModules, ...excludeModules]
|
2022-05-13 15:05:52 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
"esbuild.compileModule": async (
|
|
|
|
ctx,
|
|
|
|
moduleName: string
|
|
|
|
): Promise<string> => {
|
2022-06-13 11:06:53 +00:00
|
|
|
return await sandboxCompileModule(moduleName, builtinModules);
|
2022-04-25 17:46:08 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|