Skip to content

Commit

Permalink
fix: adjust missing inner content warning (#11394)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatiusmb authored Dec 19, 2023
1 parent 9da6508 commit 16961e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/giant-planets-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sveltejs/kit": patch
---

fix: adjust missing inner content warning
8 changes: 6 additions & 2 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,14 @@ const warning_preprocessor = {
if (!filename) return;

const basename = path.basename(filename);
if (basename.startsWith('+layout.') && !content.includes('<slot')) {
const has_children =
content.includes('<slot') || (isSvelte5Plus() && content.includes('{@render'));

if (basename.startsWith('+layout.') && !has_children) {
const message =
`\n${colors.bold().red(path.relative('.', filename))}\n` +
'`<slot />` missing — inner content will not be rendered';
`\`<slot />\`${isSvelte5Plus() ? ' or `{@render ...}` tag' : ''}` +
' missing — inner content will not be rendered';

if (!warned.has(message)) {
console.log(message);
Expand Down

0 comments on commit 16961e8

Please sign in to comment.