1
- import { loadValidatedConfig } from '@app-config/main ' ;
1
+ import { loadValidatedConfig } from '@app-config/config ' ;
2
2
import { currentEnvironment } from '@app-config/node' ;
3
+ import { generateModuleText } from '@app-config/utils' ;
3
4
import { relative } from 'path' ;
4
5
import { Transformer , upstreamTransformer } from './upstream-transformer' ;
5
6
@@ -24,26 +25,12 @@ export const transform: Transformer['transform'] = async ({ src, filename, optio
24
25
// Parse config and overwrite app-config's entry point with exported config JSON
25
26
const { fullConfig } = await loadValidatedConfig ( ) ;
26
27
27
- const modifiedSrc = generateSrc ( JSON . stringify ( fullConfig ) ) ;
28
+ const modifiedSrc = generateModuleText ( fullConfig , {
29
+ environment : currentEnvironment ( ) ,
30
+ useGlobalNamespace : false ,
31
+ validationFunctionCode : undefined ,
32
+ esmValidationCode : false ,
33
+ } ) ;
28
34
29
35
return upstreamTransformer . transform ( { src : modifiedSrc , filename, options } ) ;
30
- } ;
31
-
32
- const generateSrc = ( config : string ) => {
33
- let generatedText : string ;
34
-
35
- generatedText = `
36
- const config = ${ config } ;
37
-
38
- export { config };
39
- export default config;
40
- ` ;
41
-
42
- generatedText = `${ generatedText }
43
- export function currentEnvironment() {
44
- return ${ JSON . stringify ( currentEnvironment ( ) ) ?? 'undefined' } ;
45
- }
46
- ` ;
47
-
48
- return generatedText ;
49
- } ;
36
+ } ;
0 commit comments