Open jianzs opened 11 months ago
After merging #75, developers can now call functions that are located outside of the handler function. However, complex cases are not supported, such as calling a renamed function or a function variable. These cases are related to accessing variables #38
function test(): string {
return "hello";
}
const aliasTest = test;
const fnVar = (): string => {
return "world";
}
router.get("/", async(req: HttpRequest): HttpResponse => {
test(); // valid
aliasTest(); // error
fnVar(); // error
});
Currently, the Pluto deducer wraps each function defined in the arguments of the cloud resource handler function and treats it as a lambda resource. However, if a user tries to call another function, it will result in failure. This restriction hinders code reuse through functions.
The code provided above is not functioning correctly. To address this issue, we need to incorporate function dependency analysis into the deduction process. Furthermore, we should record this dependency information in the architecture reference, such as the resource's location. Subsequently, when generating the compute module code, we will merge all the required functions together.
The other dependencies, such as classes, interfaces, and types, can be treated the same way.