@@ -293,6 +293,13 @@ async function build_server(
293
293
294
294
find_deps ( client_entry_file , entry_js , entry_css ) ;
295
295
296
+ const adapter = config . kit . adapter ;
297
+ // const require = createRequire(import.meta.url);
298
+ // const pkg_path = require.resolve(`${adapter}/package.json`);
299
+ // const pkg = JSON.parse(fs.readFileSync(pkg_path, 'utf8'));
300
+ // const main = path.resolve(pkg_path.substring(0, pkg_path.lastIndexOf('/')), pkg.main);
301
+ console . log ( `adapter ${ adapter } ` ) ;
302
+
296
303
fs . writeFileSync (
297
304
`${ build_dir } /package.json` ,
298
305
`{
@@ -304,6 +311,12 @@ async function build_server(
304
311
}`
305
312
) ;
306
313
314
+ const entry_point = `${ output_dir } /index.js` ;
315
+ fs . writeFileSync (
316
+ entry_point ,
317
+ `import ${ s ( adapter ) } ;`
318
+ ) ;
319
+
307
320
const app_file = `${ build_dir } /app.js` ;
308
321
309
322
// prettier-ignore
@@ -467,13 +480,6 @@ async function build_server(
467
480
// don't warn on overriding defaults
468
481
const [ modified_vite_config ] = deep_merge ( default_config , vite_config ) ;
469
482
470
- const adapter = config . kit . adapter ;
471
- const require = createRequire ( import . meta. url ) ;
472
- const pkg_path = require . resolve ( `${ adapter } /package.json` ) ;
473
- const pkg = JSON . parse ( fs . readFileSync ( pkg_path , 'utf8' ) ) ;
474
- const main = path . resolve ( pkg_path . substring ( 0 , pkg_path . lastIndexOf ( '/' ) ) , pkg . main ) ;
475
- console . log ( `main ${ main } ` ) ;
476
-
477
483
/** @type {[any, string[]] } */
478
484
const [ merged_config , conflicts ] = deep_merge ( modified_vite_config , {
479
485
configFile : false ,
@@ -486,7 +492,7 @@ console.log(`main ${main}`);
486
492
polyfillDynamicImport : false ,
487
493
rollupOptions : {
488
494
input : {
489
- app : main
495
+ app : entry_point
490
496
} ,
491
497
output : {
492
498
format : 'esm' ,
0 commit comments