I read minimized tensorflow.js file for understanding module structure. Tensorflow.js is written in typescript and the above file(link) may be result of transpiling.
Anyway, I understood this module written with IIEF pattern for UMD module format. But, at end of factory function, Object.defineProperty(exports, "__esModule", { value: !0 })
exists. I know its grammatical meaning. But I do not know the purpose of this code. As far as I googled, this code seems to mark the module as ES Module. But it is not clear enough to me. So, some questions follow.
- This code seems to be removable. Does it really?
- Are there any cases for using this property?
__esModule
lets importing modules know that this is a transpiled ES module (which matters especially for default exports)." 2ality.com/2017/01/babel-esm-spec-mode.htmlimport foo from 'bar';
to: babeljs.io/en/…. Note how it checks the value of__esmodule
.