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 · 1 comment
Open

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

kvangrae opened this issue Aug 28, 2024 · 1 comment

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>

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

No branches or pull requests

1 participant