Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Sapper legacy mode: CSS not loaded on route change #1505

Closed
@rodoch

Description

@rodoch

Describe the bug
This issue occurs when using a production build (npm run build) of Sapper created with the --legacy flag in a browser which relies on the legacy code (i.e. a browser with no native support for async/await syntax).

When navigating from Page A to page B the CSS associated with the page B route is not loaded and the contents of page B remain unstyled. This does not affect the styling of any components already loaded on page A.

Logs
When testing this in Chrome 54 the console displays the following errors:

service-worker.js:1 Uncaught SyntaxError: missing ) after argument list 
(index):1 Uncaught (in promise) TypeError: Failed to register ServiceWorker: ServiceWorker script evaluation failed

However, this appears to be unrelated to the problem. Removing the service worker from the project and rebuilding does not alleviate the issue.

To Reproduce
I've created a minimal repro here: https://github.com/rodoch/sapper-legacy-repro

This is simply a copy of the sapper-template repo with Sapper & Svelte versions bumped to 0.28.6 and 3.25.0 respectively. To reproduce the problem you need to use a 'legacy' browser. I have reproduced with Chrome <= 54 and Safari <= 9 (via BrowserStack and on an old Windows machine).

  1. Start by opening the URL localhost:3000/blog. This page is styled correctly:

pic

  1. Next, navigate to the homepage. The content of this page is unstyled (e.g. the size of the success kid picture is unconstrained).

pic

This behaviour is not evident if you start on the homepage and move to the blog, presumably because a sufficient set of styles have been applied on initial page load when moving in this direction. With more complex apps this behaviour can be observed on all navigations subsequent to the initial page load.

Expected behavior
The relevant styles should be applied with each route change.

Information about your Sapper Installation:

  • The output of npx envinfo --system --npmPackages svelte,sapper,rollup,webpack --binaries --browsers
 System:
    OS: Windows 10 10.0.18363
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 5.08 GB / 15.88 GB
  Binaries:
    Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.13.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 85.0.4183.102
    Edge: Spartan (44.18362.449.0)
    Internet Explorer: 11.0.18362.1
  npmPackages:
    rollup: ^2.3.4 => 2.26.11
    sapper: ^0.28.6 => 0.28.6
    svelte: ^3.25.0 => 3.25.0
  • Your browser

Discussed above.

  • Your hosting environment (i.e. Local, GCP/AWS/Azure, Vercel/Begin, etc...)

Local + Azure deployment.

  • If it is an exported (npm run export) or dynamic application

Dynamic.

Severity
This is blocking any migration to v0.28 for me.

Additional context
I noticed a similar issue to this with modern browsers after initially migrating to v0.28.x. These issues appeared to be fixed in 0.28.6. I wonder if perhaps those changes didn't extend to the legacy mode.

I should also point out that all of necessary files (both JS and CSS) appear to be generated in __sapper__/build dir. They are simply not requested/applied on navigation.

I'm not sure if this part is relevant but it appears to be on a legacy browser that all assets which are loaded are requested from client/assets and not client/legacy/assets.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions