{"action":"created","issue":{"url":"https://api.github.com/repos/olifer655/commonJS/issues/6","repository_url":"https://api.github.com/repos/olifer655/commonJS","labels_url":"https://api.github.com/repos/olifer655/commonJS/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/olifer655/commonJS/issues/6/comments","events_url":"https://api.github.com/repos/olifer655/commonJS/issues/6/events","html_url":"https://github.com/olifer655/commonJS/issues/6","id":189598702,"number":6,"title":"ES6的模块加载和CommonJS的区别","user":{"login":"olifer655","id":9944527,"avatar_url":"https://avatars.githubusercontent.com/u/9944527?v=3","gravatar_id":"","url":"https://api.github.com/users/olifer655","html_url":"https://github.com/olifer655","followers_url":"https://api.github.com/users/olifer655/followers","following_url":"https://api.github.com/users/olifer655/following{/other_user}","gists_url":"https://api.github.com/users/olifer655/gists{/gist_id}","starred_url":"https://api.github.com/users/olifer655/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olifer655/subscriptions","organizations_url":"https://api.github.com/users/olifer655/orgs","repos_url":"https://api.github.com/users/olifer655/repos","events_url":"https://api.github.com/users/olifer655/events{/privacy}","received_events_url":"https://api.github.com/users/olifer655/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-16T05:52:59Z","updated_at":"2016-11-17T06:47:19Z","closed_at":null,"body":"1、ES6模块的设计思想，是尽量的静态化，使得`编译时`就能确定模块的依赖关系(“静态优化”)，以及输入和输出的变量。CommonJS和AMD模块，都只能在`运行时`确定这些东西(“运行时加载”)。\r\n\r\n2、ES6模块不是对象，而是通过export命令显式指定输出的代码，输入时也采用静态命令的形式。\r\n     CommonJS和AMD模块是一个对象。\r\n\r\n3、ES6模块加载的机制，与CommonJS模块完全不同。CommonJS模块输出的是一个值的拷贝，而ES6模块输出的是值的引用。\r\n\r\nCommonJS模块输出的是被输出值的拷贝，也就是说，一旦输出一个值，模块内部的变化就影响不到这个值。ES6模块是动态引用，并且不会缓存值，模块里面的变量绑定其所在的模块。\r\n\r\n4、处理“循环加载”的方法是不一样的，返回的结果也不一样。\r\n\r\nCommonJS模块的重要特性是加载时执行，即脚本代码在require的时候，就会全部执行。一旦出现某个模块被\"循环加载\"，就只输出已经执行的部分，还未执行的部分不会输出。\r\n\r\nES6模块是动态引用，如果使用`import`从一个模块加载变量，那些变量不会被缓存，而是成为一个指向被加载模块的引用，需要开发者自己保证，真正取值的时候能够取到值。"},"comment":{"url":"https://api.github.com/repos/olifer655/commonJS/issues/comments/261169157","html_url":"https://github.com/olifer655/commonJS/issues/6#issuecomment-261169157","issue_url":"https://api.github.com/repos/olifer655/commonJS/issues/6","id":261169157,"user":{"login":"olifer655","id":9944527,"avatar_url":"https://avatars.githubusercontent.com/u/9944527?v=3","gravatar_id":"","url":"https://api.github.com/users/olifer655","html_url":"https://github.com/olifer655","followers_url":"https://api.github.com/users/olifer655/followers","following_url":"https://api.github.com/users/olifer655/following{/other_user}","gists_url":"https://api.github.com/users/olifer655/gists{/gist_id}","starred_url":"https://api.github.com/users/olifer655/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olifer655/subscriptions","organizations_url":"https://api.github.com/users/olifer655/orgs","repos_url":"https://api.github.com/users/olifer655/repos","events_url":"https://api.github.com/users/olifer655/events{/privacy}","received_events_url":"https://api.github.com/users/olifer655/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T06:47:19Z","updated_at":"2016-11-17T06:47:19Z","body":"1"}}
{"actor":{"display_login":"olifer655"}}