@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
44
55import type { IProject } from '@hey-api/codegen-core' ;
66import type { DefinePlugin , OutputHeader } from '@hey-api/shared' ;
7- import { ensureDirSync , outputHeaderToPrefix } from '@hey-api/shared' ;
7+ import { ensureDirSync , isEnvironment , outputHeaderToPrefix } from '@hey-api/shared' ;
88
99import type { Config } from '../config/types' ;
1010import type { Client } from '../plugins/@hey-api/client-core/types' ;
@@ -13,13 +13,6 @@ import { getClientPlugin } from '../plugins/@hey-api/client-core/utils';
1313const __filename = fileURLToPath ( import . meta. url ) ;
1414const __dirname = path . dirname ( __filename ) ;
1515
16- /**
17- * Dev mode: determined by OPENAPI_TS_DEV_MODE environment variable
18- */
19- export function isDevMode ( ) : boolean {
20- return process . env . OPENAPI_TS_DEV_MODE === 'true' || process . env . OPENAPI_TS_DEV_MODE === '1' ;
21- }
22-
2316/**
2417 * Returns paths to client bundle files based on execution context
2518 */
@@ -29,7 +22,7 @@ function getClientBundlePaths(pluginName: string): {
2922} {
3023 const clientName = pluginName . slice ( '@hey-api/client-' . length ) ;
3124
32- if ( isDevMode ( ) ) {
25+ if ( isEnvironment ( 'development' ) ) {
3326 // Dev: source bundle folders at src/plugins/@hey -api/{client}/bundle
3427 const pluginsDir = path . resolve ( __dirname , '..' , 'plugins' , '@hey-api' ) ;
3528 return {
@@ -107,18 +100,16 @@ function renameFile({
107100function replaceImports ( {
108101 filePath,
109102 header,
110- isDevMode,
111103 renamed,
112104} : {
113105 filePath : string ;
114106 header ?: string ;
115- isDevMode ?: boolean ;
116107 renamed : Map < string , string > ;
117108} ) : void {
118109 let content = fs . readFileSync ( filePath , 'utf8' ) ;
119110
120111 // Dev mode: rewrite source bundle imports to match output structure
121- if ( isDevMode ) {
112+ if ( isEnvironment ( 'development' ) ) {
122113 // ...client_core.bundle.foo -> ..core.foo
123114 content = content . replace (
124115 / f r o m \s + ( \. { 3 , } ) \. ? c l i e n t _ c o r e \. b u n d l e \. / g,
@@ -163,7 +154,6 @@ export function generateClientBundle({
163154 project : IProject ;
164155} ) : Map < string , string > | undefined {
165156 const renamed = new Map < string , string > ( ) ;
166- const devMode = isDevMode ( ) ;
167157 const headerPrefix = outputHeaderToPrefix ( header , project ) ;
168158
169159 // copy Hey API clients to output
@@ -206,7 +196,6 @@ export function generateClientBundle({
206196 // for (const file of coreFiles) {
207197 // replaceImports({
208198 // filePath: path.resolve(coreOutputPath, file),
209- // isDevMode: devMode,
210199 // renamed,
211200 // });
212201 // }
@@ -216,7 +205,6 @@ export function generateClientBundle({
216205 replaceImports ( {
217206 filePath : path . resolve ( clientOutputPath , file ) ,
218207 header : headerPrefix ,
219- isDevMode : devMode ,
220208 renamed,
221209 } ) ;
222210 }
0 commit comments