-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Move more things out of the template
object?
#756
Comments
I feel like a JS compiler (closure compiler?) could optimize that out really easily.. |
Ideally, yeah, but neither Uglify nor Closure do, even in Closure's ADVANCED mode (it will mangle the property names but that's all). |
Some further thoughts on this. It's not that uncommon to have computed properties like this: computed: {
c: (a, b) => a + b
} In such a case, where we have an arrow function expression without a -var template = (function() {
- return {
- computed: {
- c: (a, b) => a + b
- }
- }
-}());
// ...
App.prototype._recompute = function _recompute(changed, state) {
if (changed.a || changed.b) {
- if (differs(state.c, (state.c = template.computed.c(state.a, state.b)))) changed.c = true;
+ if (differs(state.c, (state.c = state.a + state.b))) changed.c = true;
}
} It's a little trickier in a case like this... <script>
const lookup = generateLookupSomehow();
export default {
computed: {
thing: key => lookup[key]
}
};
</script> ...because The challenge that poses is that we'd need to ensure imports were deconflicted with whatever variables were declared inside the |
done in 1.40 |
This might be taking things too far, but it occurs to me that we don't really need the
template
object in a lot of cases. This code......could become this:
We're already doing this for stuff like
components
— if we did if for computed properties, lifecycle hooks and so on, we'd end up with leaner (and more minifiable) code.(Done naively, the resulting indentation would be all wrong, which 100% doesn't matter but would drive me mental. So I would want to reindent all the user code, unless someone can talk me out of that.)
The text was updated successfully, but these errors were encountered: