@@ -2,14 +2,18 @@ import * as module from "node:module";
22import * as path from "node:path" ;
33import * as url from "node:url" ;
44import { consola } from "consola" ;
5- import * as Eta from "eta" ;
5+ import { Eta } from "eta" ;
66import lodash from "lodash" ;
77import type { CodeGenProcess } from "./code-gen-process.js" ;
88import type { CodeGenConfig } from "./configuration.js" ;
99import type { FileSystem } from "./util/file-system.js" ;
1010
1111const require = module . createRequire ( import . meta. url ) ;
1212
13+ const eta = new Eta ( {
14+ functionHeader : "const includeFile = options.includeFile;" ,
15+ } ) ;
16+
1317export class TemplatesWorker {
1418 config : CodeGenConfig ;
1519 fileSystem : FileSystem ;
@@ -214,31 +218,20 @@ export class TemplatesWorker {
214218
215219 renderTemplate = (
216220 template : string ,
217- configuration : object ,
218- options : object = { } ,
221+ configuration : Record < string , unknown > ,
219222 ) => {
220223 if ( ! template ) return "" ;
221224
222- return Eta . render (
223- template ,
225+ return eta . render (
226+ eta . compile ( template , { async : false } ) ,
224227 {
225228 ...this . getRenderTemplateData ( ) ,
226229 ...configuration ,
227230 } ,
228231 {
229- async : false ,
230- ...options ,
231- includeFile : (
232- path : string ,
233- configuration : object ,
234- options : object = { } ,
235- ) => {
236- return this . renderTemplate (
237- this . getTemplateContent ( path ) ,
238- configuration ,
239- options ,
240- ) ;
241- } ,
232+ // @ts -expect-error eta's meta options lack includeFile despite runtime support
233+ includeFile : ( path : string , configuration : Record < string , string > ) =>
234+ this . renderTemplate ( this . getTemplateContent ( path ) , configuration ) ,
242235 } ,
243236 ) ;
244237 } ;
0 commit comments