Situation: When trying to make a new of a javascript function, it gives an error if the file was compiled with webpack.
Use case where it works (does not pass through webpack) SiteController.js file:
var SiteController=function() {
};
Execution inside the body of my page:
<script type="text/javascript">
$( document ).ready(function() {
new SiteController();
});
</script>
Use case where it does not work, passing the javascript files by webpack:
The javascript file after being compiled by webpack, bundle_js_app.js:
eval("\r\nvar SiteController=function() {\r\n\t\r\n};\r\n\n\n//# sourceURL=webpack:///./resources/assets/frontend/js/bin/siteController.js?");
The execution on the page remains the same:
<script type="text/javascript">
$( document ).ready(function() {
new SiteController();
});
</script>
The error:
(index): 205 Uncaught ReferenceError: SiteController is not defined at (index): 205
I do not know if I should do the new one in a different way or where the solution may be