document.addEventListener("turbolinks:load", function() {
  function inventoryButtonClickHandler(e) {
    e.preventDefault();
    let formInputs = document.getElementById('form-inputs');
    time = new Date().getTime()
    regexp = new RegExp(inventoryButton.dataset.id, 'g')
    formInputs.insertAdjacentHTML('beforebegin', inventoryButton.dataset.fields.replace(regexp, time))
  }
  let inventoryButton = document.getElementById('add-component-button');
  if (inventoryButton) {
    inventoryButton.addEventListener('click', inventoryButtonClickHandler, false);
  }
})

document.addEventListener("turbolinks:load", function() {
  function inventoryButtonClickHandler(e) {
    e.preventDefault();
    var formInputs = document.getElementById('form-inputs');
    time = new Date().getTime()
    regexp = new RegExp(inventoryButton.dataset.id, 'g')
    formInputs.insertAdjacentHTML('beforebegin', inventoryButton.dataset.fields.replace(regexp, time))
  }
  var inventoryButton = document.getElementById('add-component-button');
  if (inventoryButton) {
    inventoryButton.addEventListener('click', inventoryButtonClickHandler, false);
  }
})

Switch back to ES5 variable syntax.
Switch back to ES5 variable syntax.