WKWebView: How to load js modules to run with evaluateJavaScript

I have a wkwebview that loads an html file. That file also has script tags for multiple scripts that get loaded as modules.

I am trying to run some of the functions inside those modules using evaluateJavaScript, but I cannot either import the respective module or call any of my objects or functions inside the modules. If I create a new function and try running it from evaluateJavaScript that does work.

The errors are like "Can't find variable" or "import expects exactly one argument". What am I missing?