Svelte: Uncaught TypeError: y.fragment.l is not a function

Created on 29 May 2019  路  9Comments  路  Source: sveltejs/svelte

pending clarification

Most helpful comment

This took me awhile to figure this out. To perhaps save other folks some time, for SSR there are 3 considerations:

1. Rendering HTML

svelte.compile(code, {
  filename: "...",
  generate: 'ssr'
})

You do not need hydratable here.

2. Compile the client

svelte.compile(code, {
  filename: "...",
  generate: 'dom',
  hydratable: true
})

You do need hydratable here.

3. Render the client

App.render({
  target: document.body,
  hydrate: true
}) 

You do need hydrate here.


It makes perfect sense now, but the error is a bit terse and it seemed like a Svelte bug.

All 9 comments

There is no l method in the object that the create_fragment method puts back
21_00_24__05_29_2019

Please give a small component that reproduces this.

The l method is used in claiming nodes during hydration. Are you attempting to use hydration without compiling with hydratable: true?

Please reopen if you have a repro and the issue isn't that you are hydrating without compiling with it enabled.

The l method is used in claiming nodes during hydration. Are you attempting to use hydration without compiling with hydratable: true?

First of all, thanks. I forgot to turn it on when compiling

This took me awhile to figure this out. To perhaps save other folks some time, for SSR there are 3 considerations:

1. Rendering HTML

svelte.compile(code, {
  filename: "...",
  generate: 'ssr'
})

You do not need hydratable here.

2. Compile the client

svelte.compile(code, {
  filename: "...",
  generate: 'dom',
  hydratable: true
})

You do need hydratable here.

3. Render the client

App.render({
  target: document.body,
  hydrate: true
}) 

You do need hydrate here.


It makes perfect sense now, but the error is a bit terse and it seemed like a Svelte bug.

@Conduitry Maybe the detailed tutorial of ssr with Svelte should be an independent chapter on the official document?

It makes perfect sense now, but the error is a bit terse and it seemed like a Svelte bug.

hydratable sounds like the component should output hydratable HTML, or that it can be hydrated, so it's weird that it's an option for the client side component.

Anyway thanks for the tip @matthewmueller !

To add onto what matthewmueller said, hydratable is something you need to add to your webpack config, so Svelte compiles something that can be consumed SSR.

I think this is an area where some better error messages might help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thoughtspile picture thoughtspile  路  3Comments

AntoninBeaufort picture AntoninBeaufort  路  3Comments

1u0n picture 1u0n  路  3Comments

clitetailor picture clitetailor  路  3Comments

noypiscripter picture noypiscripter  路  3Comments