-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Global Svelte Method #67
Comments
One issue with this is that one of the goals of Svelte is to create simple modules that can be required and don't have a dependency on a version'd piece of code. The only way I could see this being useful is if we had the option of exporting modules without the stuff included in the global Svelte method and then insert the global Svelte method ourselves. |
That's what I meant by
This way, if you are building a site with Svelte components, there isn't a lot of repeated weight (which gzipping should negate, but will still have a performance tax). |
Closing this in favour of #9. We do indeed want deduplication – the best way to achieve it would be via app-level bundlers. |
Love the idea of Svelte and see a lot of great benefits for Javascript plugin authors and any developer concerned about performance & file size.
In cases with multiple Svelte components on one page or nested components, it seems like Svelte could benefit from having a global method that could be included once per page / plugin, rather than repeating the
SveltComponent
function each time. The output of Svelte CLI could have an option to inline the Svelt method into the output, or keep it separate to be included viaimport
or in a global scope.As a possible implementation of this, I've modified the scoped style example output as such:
Global method that returns a SvelteComponent:
Example of a component using the global method:
Or for Webpack / ES6 imports:
The naming conventions and exact setup may not be right, but the general idea is all I'm trying to convey.
File size for individual components with the global method included shouldn't be impacted much, but the benefits for multiple components will be huge. I don't think this is straying into "framework" territory, but is simply helpful when multiple Svelte components are being used.
The text was updated successfully, but these errors were encountered: