Closed Rich-Harris closed 7 years ago
At what point do shared helpers become a library?
My take: at the point where you as a developer have to consider them separately (including worrying about which helpers are included) from your app code — in other words, never. In most cases, we're talking about things like this...
export function detachNode(node) {
node.parentNode.removeChild(node);
}
...and I'd argue it doesn't really make sense to call that 'library code' anyway. Depends on your semantics though!
Closing this in favour of #673
The code that generates code is really quite tricky to follow. For the sake of discussion, I'll choose perhaps the easiest example:
There's a lot of noise there. I'm wondering about a different approach, whereby snippets are written in more natural JavaScript...
...and turned into data that can be manipulated like so:
Helpers can be automatically identified and aliased, and the snippets — being valid JS — can be run through Prettier etc.
We could use comment syntax as well:
(That might need a bit more work, admittedly.)
We're already doing something vaguely along these lines with the shared helpers (figuring out which helpers depend on which other ones, etc), so I reckon this is worth exploring.