File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 1+ import * as module from "node:module" ;
12import * as path from "node:path" ;
23import * as url from "node:url" ;
34import { consola } from "consola" ;
@@ -7,6 +8,8 @@ import type { CodeGenProcess } from "./code-gen-process.js";
78import type { CodeGenConfig } from "./configuration.js" ;
89import type { FileSystem } from "./util/file-system.js" ;
910
11+ const require = module . createRequire ( import . meta. url ) ;
12+
1013export class TemplatesWorker {
1114 config : CodeGenConfig ;
1215 fileSystem : FileSystem ;
@@ -74,21 +77,21 @@ export class TemplatesWorker {
7477 ) ;
7578 } ;
7679
77- requireFnFromTemplate = async ( packageOrPath : string ) => {
80+ requireFnFromTemplate = ( packageOrPath : string ) => {
7881 const isPath =
7982 packageOrPath . startsWith ( "./" ) || packageOrPath . startsWith ( "../" ) ;
8083
8184 if ( isPath ) {
82- return await import (
85+ return require (
8386 path . resolve (
8487 this . config . templatePaths . custom ||
8588 this . config . templatePaths . original ,
8689 packageOrPath ,
87- )
90+ ) ,
8891 ) ;
8992 }
9093
91- return await import ( packageOrPath ) ;
94+ return require ( packageOrPath ) ;
9295 } ;
9396
9497 getTemplate = ( name : string , fileName : string , path ?: string ) => {
You can’t perform that action at this time.
0 commit comments