[WIP] Dev helpers#378
Conversation
|
A couple of things that spring to mind - Where we're attaching the methods to the prototype, the second case (when we're not using shared helpers) isn't I believe actually strictly necessary. If we instead did [ 'get', 'fire', 'observe', 'on', 'set', '_flush' ].forEach( methodName => {
builders.main.addLine( `${name}.prototype.${methodName} = ${generator.helper( methodName )};` );
});then we'd generate a normal reference to a helper function, which would then be included later along with the other helper functions. I don't know how important declaring and assigning the methods in one go is. What I have now in the branch does save a couple of bytes in the compiled js, but having the code generation be simpler does seem nice - there has to be some duplicated logic the way it is now, Another is that the recently-added |
|
That makes sense, yeah. Though I was thinking that in shared mode, maybe the prototype itself could be shared... import { proto... } from 'svelte/shared.js';
// ...
Component.prototype = Object.assign( {}, proto, template.methods );This would shrink things down a bit further. Might make sense for component-specific Maybe I'll work that into this PR. Just about to make a start on #365 and #369 |
|
Added the shared prototype thing — will shave off a few extra bytes. @Conduitry instead of having a dev helper lookup I thought it might be easier just to check for |
|
Something that might be cool is to allow the Edit - Oh hm that's made a bit more complicated by lumping all the prototype methods into one export... |
|
Yeah, the same thought crossed my mind. I figured maybe we can see if it becomes a pain point (i.e. if the methods do indeed end up changing) and address it then, because I don't have any particularly good ideas for dealing with it right now |
Picking up where @Conduitry left off in #365 (comment) — opening a PR so we can address
#365 and #369