'vanilla js import and export in old project

I am trying to clean up the js in an old project, where I cannot add things like typescript etc.

So I am trying to split up the functionality into different files, and create some order from the chaos (I currently have multiple 10k lines js files).

For example I have an index.js which is for a specific page. On that page I am trying to call a function via an onclick to call dmrLookupByType

import * as dmrService from "../../services/DMRService.js";

// function to be called from HTML
function dmrLookupByType(type){
    console.log("called dmrLookupByType function");
    dmrService.dmrLookUp(type);
}

In DMRService.js there is a single function (so far)

export function dmrLookUp(type)
    {
        console.log("reached dmrLookup in DMRService file");
        console.log("received type: ", type);
    }

The script it self is included on the page as this.

<script type="module" src='/javascripts/src/pages/applicationCreate/index.js'></script>

But i keep getting "Uncaught ReferenceError: dmrLookupByType is not defined"

I also tried wrapping dmrservice in a class to use, but that didn't really change anything either.

Any ideas what I'm doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source