question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layouts are broken with Svelte Kit

See original GitHub issue

Describe the bug If you describe any layouts in mdsvex config, your app won’t compile in SvelteKit at all. Says something about circular dependency between generated/root.svelte and components/layout.svelte.

Logs

Logs from builder
  Circular dependency: //Users/dankozlov/Projects/temp/mdsvex-kit-repro/.svelte-kit/dev/generated/root.svelte -> /src/components/layout.svelte -> /src/components/layout.svelte
Cannot read property 'default' of null
TypeError: Cannot read property 'default' of null
    at layout.svelte:6:27
    at Object.$$render (/Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/svelte/internal/index.js:1555:22)
    at root.svelte:48:27
    at $$render (/Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/svelte/internal/index.js:1555:22)
    at Object.render (/Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/svelte/internal/index.js:1563:26)
    at render_response (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:377:28)
    at async respond$1 (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:1153:10)
    at async render_page (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:1196:20)
    at async resolve (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:1551:10)
    at async respond (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:1524:10)
Cannot read property 'default' of null
TypeError: Cannot read property 'default' of null
    at layout.svelte:6:27
    at Object.$$render (/Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/svelte/internal/index.js:1555:22)
    at root.svelte:48:27
    at $$render (/Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/svelte/internal/index.js:1555:22)
    at Object.render (/Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/svelte/internal/index.js:1563:26)
    at render_response (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:377:28)
    at async respond_with_error (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:946:10)
    at async respond$1 (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:1165:10)
    at async render_page (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:1196:20)
    at async resolve (file:///Users/dankozlov/Projects/temp/mdsvex-kit-repro/node_modules/@sveltejs/kit/dist/ssr.js:1551:10)

...

To Reproduce

Here’s a repro. But there’s nothing there, really. Just a .svx in routes and a layout in components.

Expected behavior Should work.

Information about your SvelteKit Installation:

Diagnostics
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz
    Memory: 86.83 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm
  npmPackages:
    @sveltejs/kit: next => 1.0.0-next.120 
    svelte: ^3.34.0 => 3.38.3

Severity Since Kit is in beta, I guess it’s not severe. But I consider it stable enough now, so probably should be fixed.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

8reactions
jlarforscommented, Jan 15, 2022

Something that has bitten me in two projects now is that mdsvex doesn’t seem to support Typescript.

Make sure you are not using any lang="ts" in your <script> blocks in layouts. Hopefully this helps someone else arriving here because of this.

0reactions
kmalkennethcommented, Jan 15, 2022

ok my error

Read more comments on GitHub >

github_iconTop Results From Across the Web

Layouts in SvelteKit (Nested, Groups, Resets) - YouTube
If you find my content useful and want to support the channel, you can now become a channel member! https://hbyt.us/joinSvelteKit is a ...
Read more >
Sveltekit Changes: Advanced Layouts - DEV Community ‍ ‍
Cover image for Sveltekit Changes: Advanced Layouts ... Sveltekit update: breaking changes and their explanations (7 Part Series).
Read more >
Breaking out of layouts in SvelteKit (release candidate version)
I'm developing a SvelteKit application and I have a couple pages, some of them should be public and others should have a session...
Read more >
Advanced routing • Docs • SvelteKit
Like pages, layouts can themselves break out of their parent layout hierarchy, using the same technique. For example, a +layout@.svelte component would reset ......
Read more >
Layouts – Vercel Docs
In this module, we will learn how to use the SvelteKit layout component. ... Like pages, layouts can break out of their parent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found