@@ -38,26 +38,53 @@ export async function build() {
3838 await fse . emptyDir ( OUTPUT_PRANX_DIR ) ;
3939
4040 // Bundling
41- await bundle_server ( {
42- optimize : true ,
41+ const optimize_output = false ;
42+
43+ const server_bundle_result = await bundle_server ( {
44+ optimize : optimize_output ,
4345 user_config : await get_user_pranx_config ( ) ,
4446 } ) ;
4547
4648 const browser_bundle_result = await bundle_browser ( {
47- optimize : true ,
49+ optimize : optimize_output ,
4850 user_config : await get_user_pranx_config ( ) ,
4951 } ) ;
5052
5153 // Manifests
5254 const server_site_manifest : SERVER_MANIFEST = {
5355 entry_server : join ( OUTPUT_BUNDLE_SERVER_DIR , "entry-server.js" ) ,
5456 routes : [ ] ,
57+ api : [ ] ,
5558 } ;
5659
5760 let server_entry_module : ServerEntryModule | null = null ;
5861
5962 server_entry_module = ( await import ( server_site_manifest . entry_server ) ) as ServerEntryModule ;
6063
64+ // Generating api routes Manifest
65+ const pranx_server_base_path = join ( ".pranx" , "server" ) ;
66+
67+ for ( const [ file , _output ] of Object . entries ( server_bundle_result . metafile . outputs ) ) {
68+ if ( ! file . endsWith ( "route.js" ) ) continue ;
69+
70+ const pages_relative_path = file . replace ( pranx_server_base_path , "" ) ;
71+
72+ const final_path_normalized = `/${ pages_relative_path
73+ . replace ( "route.js" , "" )
74+ . replace ( "pages" , "" )
75+ . split ( "/" )
76+ . filter ( Boolean )
77+ . join ( "/" ) } `;
78+
79+ const module_path = join ( OUTPUT_BUNDLE_SERVER_DIR , "pages" , pages_relative_path ) ;
80+
81+ server_site_manifest . api . push ( {
82+ path : final_path_normalized ,
83+ module : pages_relative_path ,
84+ absolute_module_path : module_path ,
85+ } ) ;
86+ }
87+
6188 const pranx_browser_base_path = join ( ".pranx" , "browser" ) ;
6289
6390 type CSS_OUTPUT = {
@@ -266,7 +293,7 @@ export async function build() {
266293 const html = generate_html_template ( {
267294 page_prerendered,
268295 hydrate_data_as_string,
269- minify : true ,
296+ minify : optimize_output ,
270297 css : route . css ,
271298 } ) ;
272299
0 commit comments