Fix wrong serverless handelrPath (#15675)

as title

After a sync hellp-world from twenty:
- before:

<img width="1052" height="321" alt="image"
src="https://github.com/user-attachments/assets/e008f2fd-f01e-405f-9ce0-1f14659157c6"
/>

- after:

<img width="1089" height="190" alt="image"
src="https://github.com/user-attachments/assets/3c9e301f-eabc-46e7-89e7-baf770dc0bc0"
/>
This commit is contained in:
martmull
2025-11-06 16:31:29 +01:00
committed by GitHub
parent 037663ddcd
commit d1224e1c78
2 changed files with 9 additions and 10 deletions
@@ -57,11 +57,10 @@ type JSONValue =
| { [k: string]: JSONValue };
const getProgramFromTsconfig = (
appPath?: string,
appPath: string,
tsconfigPath = 'tsconfig.json',
) => {
const basePath = appPath ?? process.cwd();
const configFile = readConfigFile(join(basePath, tsconfigPath), sys.readFile);
const configFile = readConfigFile(join(appPath, tsconfigPath), sys.readFile);
if (configFile.error)
throw new Error(
formatDiagnosticsWithColorAndContext([configFile.error], {
@@ -70,7 +69,7 @@ const getProgramFromTsconfig = (
getNewLine: () => sys.newLine,
}),
);
const parsed = parseJsonConfigFileContent(configFile.config, sys, basePath);
const parsed = parseJsonConfigFileContent(configFile.config, sys, appPath);
if (parsed.errors.length) {
throw new Error(
formatDiagnosticsWithColorAndContext(parsed.errors, {
@@ -358,13 +357,13 @@ const findHandlerAndConfig = (
};
};
const posixRelativeFromCwd = (absPath: string) => {
const rel = relative(process.cwd(), absPath);
const posixRelativeFromCwd = (fileName: string, appPath: string) => {
const rel = relative(appPath, fileName);
// normalize to posix separators for portability / manifest stability
return rel.split(sep).join(posix.sep);
};
const collectServerlessFunctions = (program: Program) => {
const collectServerlessFunctions = (program: Program, appPath: string) => {
const serverlessFunctions: ServerlessFunctionManifest[] = [];
for (const sf of program.getSourceFiles()) {
@@ -373,7 +372,7 @@ const collectServerlessFunctions = (program: Program) => {
try {
const { handlerName, configObject } = findHandlerAndConfig(sf);
const handlerPath = posixRelativeFromCwd(sf.fileName);
const handlerPath = posixRelativeFromCwd(sf.fileName, appPath);
serverlessFunctions.push({
...configObject,
@@ -516,7 +515,7 @@ export const loadManifest = async (
const [objects, serverlessFunctions, application, sources] =
await Promise.all([
Promise.resolve(collectObjects(program)),
Promise.resolve(collectServerlessFunctions(program)),
Promise.resolve(collectServerlessFunctions(program, appPath)),
Promise.resolve(extractTwentyAppConfig(program)),
loadFolderContentIntoJson(appPath),
]);
+1 -1
View File
@@ -5,4 +5,4 @@
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.spec.ts", "**/*.e2e-spec.ts", "**/__tests__/**"]
}
}