@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
44
55import type { IProject , ProjectRenderMeta } from '@hey-api/codegen-core' ;
66import type { DefinePlugin , OutputHeader } from '@hey-api/shared' ;
7- import { ensureDirSync } from '@hey-api/shared' ;
7+ import { ensureDirSync , outputHeaderToPrefix } from '@hey-api/shared' ;
88
99import type { Config } from '../config/types' ;
1010import type { Client } from '../plugins/@hey-api/client-core/types' ;
@@ -53,21 +53,6 @@ function getClientBundlePaths(pluginName: string): {
5353 } ;
5454}
5555
56- /**
57- * Converts an {@link OutputHeader} value to a string prefix for file content.
58- * Returns an empty string when the header is null, undefined, or a function
59- * (functions require a render context which is not available for bundled files).
60- */
61- function outputHeaderToPrefix ( header : OutputHeader ) : string {
62- if ( header == null || typeof header === 'function' ) return '' ;
63- const lines =
64- typeof header === 'string'
65- ? header . split ( / \r ? \n / )
66- : header . flatMap ( ( line ) => line . split ( / \r ? \n / ) ) ;
67- const content = lines . join ( '\n' ) ;
68- return content ? `${ content } \n\n` : '' ;
69- }
70-
7156/**
7257 * Returns absolute path to the client folder. This is hard-coded for now.
7358 */
@@ -186,11 +171,11 @@ export function generateClientBundle({
186171 meta : ProjectRenderMeta ;
187172 outputPath : string ;
188173 plugin : DefinePlugin < Client . Config & { name : string } > [ 'Config' ] ;
189- project ? : IProject ;
174+ project : IProject ;
190175} ) : Map < string , string > | undefined {
191176 const renamed = new Map < string , string > ( ) ;
192177 const devMode = isDevMode ( ) ;
193- const headerPrefix = outputHeaderToPrefix ( header ) ;
178+ const headerPrefix = outputHeaderToPrefix ( header , project ) ;
194179
195180 // copy Hey API clients to output
196181 const isHeyApiClientPlugin = plugin . name . startsWith ( '@hey-api/client-' ) ;
0 commit comments