What is this harmony exports? In fact, what is harmony?
Background
When I bundle stuff using Webpack and I look at the distribution source, it contains this one block always.
// define getter function for harmony exports
__webpack_require__.d = function(exports, name, getter) {
if(!__webpack_require__.o(exports, name)) {
Object.defineProperty(exports, name, { enumerable: true, get: getter });
}
};
I Googled and found this page but I understand nothing on it. As of today, this page reads like so:
I googled more and found a similar question asking what harmony is, but the asker never asked it in so many words and the only answer does not tell you what it is.
Question
So, what on God's own green earth is harmony? And then what are harmony exports?
Reading the Stack Overflow tag description for 'ecmascript-harmony', I suspect it refers to ES6 module exports but I also think it isn't that, because immediately afterwards, the Webpack source distribution file has an if
construct checking for whether the entry
file it is processing exposes an ES 6 Module using the export
statement.
// define __esModule on exports
__webpack_require__.r = function(exports) {
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
}
Object.defineProperty(exports, '__esModule', { value: true });
};
So, it probably means something other than ES 6 modules exports? I suspect it is the Common JS style export as implemented in Node?
So, what on God's own green earth is harmony?
After ES4 was abandoned, plans were scaled back in a new project which had the code name Harmony.
This eventually evolved into ES6.
And then what are harmony exports?
The exports system that ES6 describes the final (?) version of.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With