I can't seem to find a description of the way I should export global variable from ES6 module. Is there a resource where it's defined?
The only solution that seems to work is referencing a global object, like window
:
window['v'] = 3;
But what if this scripts runs in Node.js? Then I don't have window
; I have global
. But this code is not good:
var g = window || global;
g['v'] = 3;
I understand the concept of modules and don't use globals in my applications. However, having global variables during debugging in the console may be beneficial, especially when using bundlers like Webpack instead of loaders like SystemJs where you can easily import a module in a console.