You don't, because they aren't properties of the global object (which is referenced via window
on browsers). They aren't globals at all. Which is a Good Thing.™ :-)
You could create your own object with those functions on it, and use it instead:
import { myFunc } from './myFunc.js';
const funcs = {
myFunc
};
Usage:
let fnStr = "myFunc";
let fn = funcs[fnStr];
fn();
If you have several of these functions, you might want to export them on an object rather than as individual bindings, e.g.:
myFuncs.js
:
function myFunc() {
// ...
}
function myOtherFunc() {
// ...
}
export default {myFunc, myOtherFunc};
then
import funcs from './myFuncs.js';
let fnStr = "myFunc";
let fn = funcs[fnStr];
fn();