Sapper: (v3) `preload` in context="module" not registering until restart

Created on 16 Mar 2019  路  4Comments  路  Source: sveltejs/sapper

This might be a Svelte issue, but filing it here.

There's a weird thing happens in v3 Sapper/Svelte where preload works in some components/pages and not others. Even identical code within preload.

Turns out it _does_ work the same in these components/pages. One just has to completely restart Sapper for the new context="module" script to register the preload.

Example without restart:

Given:

<script>export let user;</script>

One will see the following error:

was created without expected prop 'user'

Restarting, the error goes away, and preload works.

bug

Most helpful comment

I can confirm that I'm still seeing this issue

All 4 comments

I'm hoping this was fixed in 0.27.5 by #713.

Still seeing this in v0.27.8.

I can confirm that I'm still seeing this issue

The create_manifest_data function has the logic has_preload (https://github.com/sveltejs/sapper/blob/master/src/core/create_manifest_data.ts#L16) which value is cached in the data_manifest.components structure. When files in the src/routes are added/removed the preloads are rechecked, however this doesn't happen when the content of an individual page is updated. So this problem seem to occur when an empty route/page is added and the preload function is added/removed at a later time. The preload is important because it affects the code generation in create_app (https://github.com/sveltejs/sapper/blob/master/src/core/create_app.ts#L169).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rich-Harris picture Rich-Harris  路  3Comments

Rich-Harris picture Rich-Harris  路  3Comments

Rich-Harris picture Rich-Harris  路  3Comments

nikku picture nikku  路  4Comments

antony picture antony  路  3Comments