{"action":"created","issue":{"url":"https://api.github.com/repos/seajs/seajs/issues/1511","labels_url":"https://api.github.com/repos/seajs/seajs/issues/1511/labels{/name}","comments_url":"https://api.github.com/repos/seajs/seajs/issues/1511/comments","events_url":"https://api.github.com/repos/seajs/seajs/issues/1511/events","html_url":"https://github.com/seajs/seajs/issues/1511","id":77336771,"number":1511,"title":"一个模块同步 require 无返回， async.require 有返回，如何理解错误出现在什么地方？","user":{"login":"kmvan","id":3839554,"avatar_url":"https://avatars.githubusercontent.com/u/3839554?v=3","gravatar_id":"","url":"https://api.github.com/users/kmvan","html_url":"https://github.com/kmvan","followers_url":"https://api.github.com/users/kmvan/followers","following_url":"https://api.github.com/users/kmvan/following{/other_user}","gists_url":"https://api.github.com/users/kmvan/gists{/gist_id}","starred_url":"https://api.github.com/users/kmvan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmvan/subscriptions","organizations_url":"https://api.github.com/users/kmvan/orgs","repos_url":"https://api.github.com/users/kmvan/repos","events_url":"https://api.github.com/users/kmvan/events{/privacy}","received_events_url":"https://api.github.com/users/kmvan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-17T15:56:06Z","updated_at":"2015-05-24T03:26:48Z","closed_at":"2015-05-24T03:26:48Z","body":"模块 a，别名是 a，实际路径是 a.php?xxx=a.js，内容是 :\r\n```js\r\n// code 0\r\n// module a\r\ndefine({\r\n\t\"user\": {\r\n\t\t\"logged\": false\r\n\t},\r\n\t\"theme-nonce\": \"202462219c\"\r\n});\r\n```\r\n上面的模块 a，是存在的，返回文件类型是 js，但可能会有***数秒的 loading 延迟***。\r\n那么问题来了，我在模块 b 中调用 a，如下：\r\n```js\r\n// code 1\r\n// module b\r\ndefine(function(require, exports, module){\r\n\tvar a = require('theme-cache-request');\r\n\tconsole.log(a);\r\n});\r\n```\r\n此时 b 模块居然没有任何东西被输出，但 a 模块已经能在请求中看到。将 b 模块换成异步调用：\r\n```js\r\n// code 2\r\n// module b async\r\ndefine(function(require, exports, module){\r\n\tasync.require(['theme-cache-request'],function(a){\r\n\t\tconsole.log(a);\r\n\t});\r\n});\r\n```\r\n此时 b 模块异步调用 a，能获取 a 的返回对象。\r\n\r\n那我就想不通了，为啥会出现这种情况，没有任何错误提示哦。而且在 code 1 的例子里面，有时候浏览器刷新多几次，说不定就***有一次能成功输出 a***。感觉好奇怪啊。\r\n我猜测有可能是因为 a 模块由 php 输出，有一定的 loading 时长，所以导致了一些奇怪的问题。（等会去试验一下）\r\n不知道各位有没有遇过？"},"comment":{"url":"https://api.github.com/repos/seajs/seajs/issues/comments/104974301","html_url":"https://github.com/seajs/seajs/issues/1511#issuecomment-104974301","issue_url":"https://api.github.com/repos/seajs/seajs/issues/1511","id":104974301,"user":{"login":"kmvan","id":3839554,"avatar_url":"https://avatars.githubusercontent.com/u/3839554?v=3","gravatar_id":"","url":"https://api.github.com/users/kmvan","html_url":"https://github.com/kmvan","followers_url":"https://api.github.com/users/kmvan/followers","following_url":"https://api.github.com/users/kmvan/following{/other_user}","gists_url":"https://api.github.com/users/kmvan/gists{/gist_id}","starred_url":"https://api.github.com/users/kmvan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmvan/subscriptions","organizations_url":"https://api.github.com/users/kmvan/orgs","repos_url":"https://api.github.com/users/kmvan/repos","events_url":"https://api.github.com/users/kmvan/events{/privacy}","received_events_url":"https://api.github.com/users/kmvan/received_events","type":"User","site_admin":false},"created_at":"2015-05-24T03:26:48Z","updated_at":"2015-05-24T03:26:48Z","body":"虽然不是很明白……"}}