diff --git a/packages/core/src/App.ts b/packages/core/src/App.ts index c82bff35..705c8510 100644 --- a/packages/core/src/App.ts +++ b/packages/core/src/App.ts @@ -44,7 +44,7 @@ interface EventCache { class App extends EventEmitter { public env; - public codeDsl: CodeBlockDSL; + public codeDsl: CodeBlockDSL | undefined; public pages = new Map(); public page: Page | undefined; diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index 622cfb4b..ad61527c 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -85,9 +85,9 @@ class Node extends EventEmitter { } private async runCodeBlock(hook: string) { - if (!Array.isArray(this.data[hook]) || isEmpty(this.app?.codeDsl)) return; + if (!Array.isArray(this.data[hook]) || !this.app.codeDsl || isEmpty(this.app?.codeDsl)) return; for (const codeId of this.data[hook]) { - if (this.app?.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') { + if (this.app.codeDsl[codeId] && typeof this.app?.codeDsl[codeId]?.content === 'function') { await this.app.codeDsl[codeId].content(this); } }