Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use $$restProps in runes mode (Svelte 5) #48

Open
kvangrae opened this issue Aug 28, 2024 · 7 comments · May be fixed by #51
Open

Cannot use $$restProps in runes mode (Svelte 5) #48

kvangrae opened this issue Aug 28, 2024 · 7 comments · May be fixed by #51

Comments

@kvangrae
Copy link

kvangrae commented Aug 28, 2024

When using svelte-time as a dependency in my project and compiling in runes mode using Svelte 5:

svelte.config.js

export default {
    compilerOptions: {
        runes: true
    }
};

I get the following error:

✘ [ERROR] node_modules/svelte-time/Time.svelte:65:18 Cannot use `$$restProps` in runes mode [plugin vite-plugin-svelte:optimize-svelte]                                                                 
                                                                                                                                                                                                        
    node_modules/svelte-time/Time.svelte:65:18:                                                                                                                                                         
      65 │ time {title} {...$$restProps} datetime={timestamp}>                                                                                                                                          
         ╵                   ^                                                                                                                                                                          
                                                                                                                                                                                                        
  The plugin "vite-plugin-svelte:optimize-svelte" was triggered by this import                                                                                                                          
                                                                                                                                                                                                        
    node_modules/svelte-time/index.js:3:24:                                                                                                                                                             
      3 │ export { default } from "./Time.svelte";                                                                                                                                                      
        ╵                         ~~~~~~~~~~~~~~~                                                                                                                                                       

This is a limitation for other projects that are using Svelte 5 and runes.

@kvangrae
Copy link
Author

When upgrading to support Svelte 5 and runes, you can replace $$restProps with $props.

Example:

<script>
    ...
    const props = $props();
    ...
</script>

<time {title} {...props} datetime={timestamp}>
    {formatted}
</time>

@niemyjski
Copy link

$: is also not allowed

https://github.com/metonym/svelte-time/blob/master/src/Time.svelte#L51C1-L62

@niemyjski
Copy link

@kvangrae any chance you could submit a pr for this?

@kvangrae
Copy link
Author

kvangrae commented Dec 9, 2024

@kvangrae any chance you could submit a pr for this?

Sure, no problem. Let me get back to you.

@kvangrae kvangrae linked a pull request Dec 10, 2024 that will close this issue
@kvangrae
Copy link
Author

@niemyjski have a look at pull request #51 and let me know what you think.

@niemyjski
Copy link

@kvangrae looks good, left one comment. @metonym can we get this merged and a release going.

@metonym
Copy link
Owner

metonym commented Jan 11, 2025

Is there a rough estimation as to how many Svelte users explicitly opt-in to Runes mode?

If runes mode is not the default in Svelte 5, is it possible that this user base is smaller than Svelte 3/4/5 (non-runes mode)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants