Any code in the login file is executed in close. If you look at the bundle.js created, you will see something like this there.
function(require, module, exports) { function fnClick() { alert(getMessage()); } }
Everything that you create here will simply be hidden in the global space unless you explicitly use the window object (but do not ) to open it.
As @elclanrs explained in the comments above, just attach only the receiver in your code instead of HTML. If you do not want to use external libraries, you can do this with difficulty.
var button = document.getElementById('my-button'); // add id="my-button" into html button.addEventListener('click', fnClick);
Or with a library like the popular jQuery that you just call.
$('#my-button').click(fnClick)
source share