I have an html file with the following script:
<script type="module" src="js/app.js"></script>
This is where I put my app logic with other imports. Inside this app.js file, I have a function called test();
function test() {
    console.log("aaa");
}
This function is called in an onclick event in an HTML span element appended dynamically using this code:
buildSideBar(technologies) {
    if(technologies.length > 0) {
        let spans = ``;
        const loader = document.getElementById('loader');
        const sidebar = document.getElementById('sidebar');
        for(const technology of technologies) {
            spans += `<span onclick="test()">${technology}</span>`;
        }
        loader.style.height = '0';
        loader.style.visibility = 'hidden';
        sidebar.innerHTML += spans;
        sidebar.classList.remove('hidden');
    }
}
The spans are added as intended, however, when I press them I get an error:
Uncaught ReferenceError: test is not defined
at HTMLSpanElement.onclick ((index):1)
What am I doing wrong here?
 
    