Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

On many pages, only the last example loads (upstream issue) #148

Open
aaronharder opened this issue Mar 1, 2021 · 9 comments
Open

On many pages, only the last example loads (upstream issue) #148

aaronharder opened this issue Mar 1, 2021 · 9 comments
Labels
documentation Improvements or additions to documentation

Comments

@aaronharder
Copy link

Hello, great project! I'm seeing that many of the examples in your docs appear to be missing.

Just one example: https://svelte-materialify.vercel.app/components/button-groups/

Screen grab:
chrome_DiE4oMxoXc

This issue is happening for me throughout the docs. Not every example, but many of them. Hoping it's a quick fix once the cause of this issue is identified.

Thanks for a great library of components!

@Florian-Schoenherr
Copy link
Collaborator

@aaronharder try to change page to another component and then back to the one you want to look at (e.g. ButtonGroup -> Button -> ButtonGroup). We haven't found the problem yet, it could be due to a version upgrade (on sapper/rollup/?).
@TheComputerM any ideas? When I tested, the dynamic imports still worked (logged out the module).

@TheComputerM
Copy link
Owner

Don't know, most probably sapper updating might be the cause or could be bad file paths.

@aaronharder
Copy link
Author

Downloaded locally and did a little debugging. Looking at this line:

import(`../../examples/${dir}/${name}.svelte`).then((data) => {

Seems like the import is definitely being attempted every time, but is frequently failing. Tried adding a ".catch()" to my local copy, but nothing came through. Apparently the promise returned by import() just hangs and never returns sometimes? Anyway, seems definitively like a problem not of your making. Too bad. Thanks for looking!

@aaronharder
Copy link
Author

Hello again. I noticed that it is the LAST <Components.Example /> instance on a given page that ALWAYS works fine. This piqued my curiosity so I dug into the Sapper code and found what I believe to be the root issue in their CSS inject_styles mechanism. If you look at this code from Sapper:

https://github.com/sveltejs/sapper/blob/6ef55208699f223ca3e12184362400ce3f2e3db8/src/core/create_compilers/RollupCompiler.ts#L53

They're tying their Promise resolution to a link.onload assignment. However, multiple assignments to the same link element will of course only result in the LAST one working. To fix, I hand-patched the Sapper code to replace the onload and onerror assignments with their addEventListener equivalents:

          link.addEventListener('load', function () {
            return fulfil();
          });
          link.addEventListener('error', reject);

In my local tests, this fixes the problem!

Not sure if you guys might have more clout than I do in reporting this issue to the Sapper project. If so, I'm happy for you to report it. If not, let me know and I will be glad to make a report.

Thanks again for your great work on these Material components for Svelte.

@Florian-Schoenherr
Copy link
Collaborator

Florian-Schoenherr commented Mar 2, 2021

@TheComputerM you seem to have some more clout?
@aaronharder last instance was what I noticed too, forgot to mention that. If @TheComputerM doesn't report in a matter of 24 hours, please go ahead!
This btw is a regression, it worked before (most probable cause: sapper ^0.28.10 -> ^0.29.0)
Edit: Just looked into all changes from 28.10 - 29.0, maybe it's not that.

@TheComputerM
Copy link
Owner

I don't think sapper will be receiving any more updates.

@aaronharder
Copy link
Author

Makes sense. Maybe when you/if you guys move the Materialify site to SvelteKit etc this issue will no longer exist. Thanks again!

@Florian-Schoenherr Florian-Schoenherr changed the title Many examples broken/missing in docs On many pages, only the last example loads (upstream issue) Mar 8, 2021
@Florian-Schoenherr Florian-Schoenherr added the documentation Improvements or additions to documentation label Mar 8, 2021
@Florian-Schoenherr
Copy link
Collaborator

@TheComputerM why exactly do we not fix this? Will sapper not merge such a PR anymore?

@Florian-Schoenherr Florian-Schoenherr pinned this issue Mar 26, 2021
@bato3
Copy link

bato3 commented Apr 22, 2021

@Florian-Schoenherr My info can be outdated, but when a year ago I ask a similar question, they gave me an answer:

We are focusing on Svelte, and until it isn't to be stable we stop to maintain Sapper. (Some changes in Svelte may affect the Sapper.)

//Edit:

From FAQ:

No new features will be added to Sapper and all development will be focused on SvelteKit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants