Closed
Description
This Rollup issue got me thinking. #992 moved away from the concept of 'visitors' to the current approach, whereby AST nodes are converted into classes that implement common methods like build
alongside more specialised ones.
It works, but:
- it means we have to clone the AST, so that it can be included in the
svelte.compile
output - there are performance downsides to changing prototypes
- we're locked in to the structure of the AST generated by
svelte.parse
, which isn't necessarily the best structure for later phases (e.g. bindings and event handlers are lumped in with attributes). I don't think there's any guarantee that the parser could create the optimal structure
So what I propose, in essence, is that instead of augmenting the existing AST nodes we create entirely new objects. Instead of
Object.setPrototypeOf(node, EachBlock.prototype);
it would be
new EachBlock(node);
and the EachBlock
constructor would be responsible for instantiating its children.
Metadata
Metadata
Assignees
Labels
No labels