My current Rails 7 application utilizes esbuild as the JS bundler and has bootstrap imported. I am facing an issue where I am unable to access any Bootstrap Javascript functionality outside of the main application.js file. For example, I am attempting to programmatically display a Bootstrap modal on a specific page using the following code:
var myModal = new bootstrap.Modal(document.getElementById('helpModal'), {});
myModal.modal('show');
However, I am encountering an error as 'bootstrap' is not recognized:
Uncaught ReferenceError: bootstrap is not defined
Even though the page includes application.js:
<%= javascript_include_tag "application", defer: true %>
Do you have any suggestions on how to access 'bootstrap' in JS outside of the application.js file itself?
Thank you!