Skip to content

Commit 11ec751

Browse files
fix build warnings in user app about missing exports in hooks (#1003)
* fix build warnings in user app about missing exports in hooks * add comment, so we don't make the same mistake again Co-authored-by: Rich Harris <[email protected]>
1 parent c02e224 commit 11ec751

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

.changeset/quiet-ants-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Fix build warnings about missing exports in hooks file

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,15 @@ async function build_server(
300300
]
301301
};
302302
303-
const hooks = {
304-
getContext: user_hooks.getContext || (() => ({})),
305-
getSession: user_hooks.getSession || (() => ({})),
306-
handle: user_hooks.handle || (({ request, render }) => render(request))
307-
};
303+
// this looks redundant, but the indirection allows us to access
304+
// named imports without triggering Rollup's missing import detection
305+
const get_hooks = hooks => ({
306+
getContext: hooks.getContext || (() => ({})),
307+
getSession: hooks.getSession || (() => ({})),
308+
handle: hooks.handle || (({ request, render }) => render(request))
309+
});
310+
311+
const hooks = get_hooks(user_hooks);
308312
309313
const module_lookup = {
310314
${manifest.components.map(file => `${s(file)}: () => import(${s(app_relative(file))})`)}

0 commit comments

Comments
 (0)