> There's also ... [...]
(I assume you meant to write your example in CommonJS style, because that's not valid a ES6 export, they must be top-level).
Doesn't your example highlight exactly why even executing the code wouldn't even help you there?
(I assume you meant to write your example in CommonJS style, because that's not valid a ES6 export, they must be top-level).
Doesn't your example highlight exactly why even executing the code wouldn't even help you there?
You can't, at least not in this way. A module's imported and exported names are statically determined. Of course, you can just export a single object, and then make that object arbitrarily complex depending on runtime behavior.
> Like being able to require modules locally
Not sure what this means.