framework7io / framework7

Full featured HTML framework for building iOS & Android apps
http://framework7.io
MIT License
18.06k stars 3.23k forks source link

Unable to use `immutable` optional in Svelte config #4086

Open darbymanning opened 1 year ago

darbymanning commented 1 year ago

Describe the bug

When using the immutable compiler option in Svelte, the router seems to be non-functioning. Clicking a link doesn't navigate to the new URL and the view remains unchanged.

To Reproduce

Steps to reproduce the behaviour:

  1. Create a new Framework7 Project with Svelte (I've been using the tabs template in my tests)
  2. In vite.config.js, update the svelte plugin to set immutable to true
    plugins: [svelte({ compilerOptions: { immutable: true } })],
  3. Observe that the tabs themselves operate correctly ✅
  4. Click on 'About' or 'Form' under Navigation
  5. View/route remains unchanged

Expected behaviour

Navigation should work as expected taking the user to the new view.

Potential solution

In my troubleshooting, one solution could be to explicitly set immutable to false inside framework7-svelte/components/view.svelte.

<svelte:options immutable={false} />

This resolves the issue, and wouldn't present a breaking change as immutable is currently presumed to be false, as this is a Svelte default. I'm new to Framework7 though, so I am not sure if a <Link> can be used outside of the context of a <View>, which case perhaps we need to set this in a few different components.