My code has various imports that I use exactly once.
I can bind an import to a variable, then use it like so:
module.js
export default 'hello';
main.js
import greeting from './module.js';
console.log(greeting);
But if I have many imports, I have to think of many arbitrary variable names.
Is there a way to use the import, yet skip the creation of this variable greeting
? The kind of thing that I have in mind is something like this:
console.log(import './module.js';);
But that particular syntax does not exist (at least, Babel interprets this as a SyntaxError: Unexpected token at console.log(i…
). Is there a way to do this in ES6?