I read plenty of other implementations on how to do this, but didn't care for any of them so here is my take on a drop-in solution for svg text wrapping.
// set up your "text box" element however you want (without any text yet):
var textX = 150;
var textEl = techtree.treeSVG.append('text')
.attr('x',textX)