Closed Mitcheljager closed 1 month ago
I don't see how SvelteKit should be able to recover from any of this. If a JavaScript file is blocked from executing that is needed for the site to function, it will obviously crash in unexpected ways. What are you imagining should happen in such a case?
It would be nice if it could fail silently. Components like this are optional, and I'm fine with them not executing at all. But even in cases where I do want component to execute, there are going to be cases where Adblockers falsely flag a particular file. The entire site not working because of that is just not a viable outcome.
Adblockers are very present and used by a large enough portion of users that we can't realistically just ignore them.
How should Svelte(Kit) know that components "like this" are optional? We can't know, and safeguarding every possible import to fail within the code isn't practical either.
In general, in situations like this it's best to try to architect the site in such a way that it also works without JavaScript so that things like this aren't that impactful.
I use uBlock Origin on Chromium, but it blocks nothing on both stackblitz and localhost.
I suppose, a dynamic import and svelte:component
is a workaround.
Here's a thought. The files are blocked purely based on the filename. What if there was a parameter that could be toggled to randomize the filenames for each component, setting them to random strings?
Describe the bug
When any component is blocked by an Ad Blocker the whole site crashes and any functionality seizes to function. The error reads
TypeError: error loading dynamically imported module
.I am using uBlock Origin on FireFox and Chrome. We've had other reports from this happening using AdBlock on Chrome. On Safari the issue seemed to be more muted, with the site still functioning despite the components being blocked as expected, but I was not able to confirm this myself.
Additionally in our project the page begins to redirect infinitely to itself, causing a constant looping reload. I could however not reproduce this in a clean project, but I thought it was worth noting.
Reproduction
-
and+
buttons.Here is an example of a completely clean project, there is nothing new in there except for the
ExternalAd.svelte
componenthttps://stackblitz.com/edit/sveltejs-kit-template-default-1rvavc?file=src%2Froutes%2F%2Blayout.svelte
I tested it locally as well, and the same happens as on the StackBlitz page.
Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
This issue might be related; https://github.com/sveltejs/kit/issues/2699