I cannot find a description of how I should export a global variable from an ES6 module. Is there a resource where it is defined?
The only solution that seems to work is referencing a global object, such as window :
window['v'] = 3;
But what if these scripts work in Node.js? Then I do not have window ; I have global . But this code is not very good:
var g = window || global; g['v'] = 3;
I understand the concept of modules and do not use global variables in my applications . However, having global variables during debugging in the console can be useful, especially when using packages such as Webpack, rather than loaders like SystemJ, where you can easily import the module into the console.
javascript ecmascript-6 module
AngularInDepth.com
source share