Professional JavaScript for Web Developers 第四版學習筆記 CHAPTER 25:MODULES
Understanding the module pattern 946
Module Identifiers 946
Module Dependencies 946
Module Loading 946
Entry Points 947
Asynchronous Dependencies 948
Programmatic Dependencies 948
Static Analysis 948
Circular Dependencies 949
Improvising Module Systems 950
Working with pre-ES6 module loaders 953
CommonJS 953
Asynchronous Module Definition 956
Universal Module Definition 957
Module Loader Deprecation 957
Working with ES6 modules 958
Module Tagging and Definition 958
Module Loading 959
Module Behavior 959
Module Exports 960
Module Imports 963
Module Passthrough Exports 965
Worker Modules 965
Backwards Compatibility 966
Summary 967
-----------------------------------------------------------------------------
Splitting code into independent pieces and connecting those pieces together can be robustly implemented with the module pattern. The central ideas for this pattern are simple: break logic into pieces that are totally encapsulated from the rest of the code, allow each piece to explicitly define what parts of itself are exposed to external pieces, and allow each piece to explicitly define what external pieces it needs to execute. There are various implementations and features that complicate these concepts,but these fundamental ideas are the foundation for all module systems in JavaScript.
--------------------------------------------------
Modules defined inline cannot be loaded into other modules using import. Only modules loaded from an external file can be loaded using import. Therefore, inline modules are only useful as an entry point module.