Skip to content

Commit 2541eb6

Browse files
authoredJul 19, 2024··
fix: adding additional logging when importing/requiring a module in case the hook script is invalid or unable to be executed (#8356)
1 parent fb16669 commit 2541eb6

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed
 

‎.changeset/polite-impalas-shout.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"app-builder-lib": patch
3+
---
4+
5+
fix: adding additional logging when importing/requiring a module in case the hook script is invalid or unable to be executed

‎packages/app-builder-lib/src/platformPackager.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -778,10 +778,15 @@ async function resolveModule<T>(type: string | undefined, name: string): Promise
778778
const fileUrl = pathToFileURL(name).href
779779
return await eval("import('" + fileUrl + "')")
780780
}
781-
} catch (error) {
782-
log.debug({ moduleName: name }, "Unable to dynamically import hook, falling back to `require`")
781+
} catch (error: any) {
782+
log.debug({ moduleName: name, message: error.message ?? error.stack }, "Unable to dynamically import hook, falling back to `require`")
783+
}
784+
try {
785+
return require(name)
786+
} catch (error: any) {
787+
log.error({ moduleName: name, message: error.message ?? error.stack }, "Unable to `require` hook")
788+
throw new Error(error.message ?? error.stack)
783789
}
784-
return require(name)
785790
}
786791

787792
export async function resolveFunction<T>(type: string | undefined, executor: T | string, name: string): Promise<T> {

0 commit comments

Comments
 (0)
Please sign in to comment.