I am looking to streamline the process of importing and using functions from a different file. Ideally, I would like to simply call these functions by their name without any extra prefixes or naming conventions. However, I am aware that using eval()
can pose security risks.
So far, I have explored two methods but neither seem perfect for my needs:
The first method requires explicitly naming each function when importing, which could become cumbersome with a large number of functions in the external file.
import { doSomething } from './functions.js';
The second method involves specifying a prefix before each external function, which adds unnecessary complexity.
import * as f from './functions.js';
What I envision is something simpler, where all functions are imported and can be called directly:
import * from './functions.js';
This way, calling functions like this becomes straightforward:
helloWorld();
makeMeSomeCoffee();
My goal is to efficiently share common functions among multiple electron windows while maintaining modularity and following the DRY principle.
If you have any suggestions on how to achieve this seamless integration, I would greatly appreciate it!