Quite simple:
oninput='this.style.width = (this.scrollWidth - N) + "px";'
Where N is some number (2 in the example, 17 on something I'm developing) that is determined experimentally.
Subtracting N prevents this strange extrenuous space from accumulating long before the text reaches the end of the text box.
Compare. Pay careful attention to how the size changes after even just the first character.
<p>Subtracting N:</p> _x000D_
<input type="text" placeholder="enter lots of text here" oninput='this.style.width = (this.scrollWidth-2) + "px";'>_x000D_
_x000D_
<p>Not Subtracting N:</p> _x000D_
<input type="text" placeholder="enter lots of text here" oninput='this.style.width = (this.scrollWidth) + "px";'>
_x000D_