Skip to content

Commit 1d854b7

Browse files
committed
WIP
1 parent 9bc8d89 commit 1d854b7

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/kit/src/core/build/index.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,13 @@ async function build_server(
293293

294294
find_deps(client_entry_file, entry_js, entry_css);
295295

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+
296303
fs.writeFileSync(
297304
`${build_dir}/package.json`,
298305
`{
@@ -304,6 +311,12 @@ async function build_server(
304311
}`
305312
);
306313

314+
const entry_point = `${output_dir}/index.js`;
315+
fs.writeFileSync(
316+
entry_point,
317+
`import ${s(adapter)};`
318+
);
319+
307320
const app_file = `${build_dir}/app.js`;
308321

309322
// prettier-ignore
@@ -467,13 +480,6 @@ async function build_server(
467480
// don't warn on overriding defaults
468481
const [modified_vite_config] = deep_merge(default_config, vite_config);
469482

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-
477483
/** @type {[any, string[]]} */
478484
const [merged_config, conflicts] = deep_merge(modified_vite_config, {
479485
configFile: false,
@@ -486,7 +492,7 @@ console.log(`main ${main}`);
486492
polyfillDynamicImport: false,
487493
rollupOptions: {
488494
input: {
489-
app: main
495+
app: entry_point
490496
},
491497
output: {
492498
format: 'esm',

0 commit comments

Comments
 (0)