Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change suggested by @tomcon — we can move more initialisation work into shared functions. The reason it's the way it is currently is to avoid adding extra code for components that don't need it, but realistically this just makes the typically app larger for the sake of sometimes making standalone components smaller.
Taking the realworld app as an example, this PR reduces the total JS size to 157,336 bytes from 160,200, a 1.8% reduction. (Granted, after zipping the difference is almost zilch — 34141 from 34145 — but that's after concatenating all the code-split chunks, and in any case minimising the JS that needs to be parsed and eval'd is the larger goal.)
Compiling a standalone
<h1>hello {name}</h1>
component goes up from 2,391 to 2,469 bytes, a 3.3% increase. That's a more 'visible' increase for someone evaluating Svelte for the first time, but maybe that's ok?