{"action":"created","issue":{"url":"https://api.github.com/repos/mipengine/mip2/issues/327","repository_url":"https://api.github.com/repos/mipengine/mip2","labels_url":"https://api.github.com/repos/mipengine/mip2/issues/327/labels{/name}","comments_url":"https://api.github.com/repos/mipengine/mip2/issues/327/comments","events_url":"https://api.github.com/repos/mipengine/mip2/issues/327/events","html_url":"https://github.com/mipengine/mip2/issues/327","id":374972197,"node_id":"MDU6SXNzdWUzNzQ5NzIxOTc=","number":327,"title":"显式声明 MIP 组件依赖","user":{"login":"clark-t","id":9402832,"node_id":"MDQ6VXNlcjk0MDI4MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/9402832?v=4","gravatar_id":"","url":"https://api.github.com/users/clark-t","html_url":"https://github.com/clark-t","followers_url":"https://api.github.com/users/clark-t/followers","following_url":"https://api.github.com/users/clark-t/following{/other_user}","gists_url":"https://api.github.com/users/clark-t/gists{/gist_id}","starred_url":"https://api.github.com/users/clark-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clark-t/subscriptions","organizations_url":"https://api.github.com/users/clark-t/orgs","repos_url":"https://api.github.com/users/clark-t/repos","events_url":"https://api.github.com/users/clark-t/events{/privacy}","received_events_url":"https://api.github.com/users/clark-t/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"clark-t","id":9402832,"node_id":"MDQ6VXNlcjk0MDI4MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/9402832?v=4","gravatar_id":"","url":"https://api.github.com/users/clark-t","html_url":"https://github.com/clark-t","followers_url":"https://api.github.com/users/clark-t/followers","following_url":"https://api.github.com/users/clark-t/following{/other_user}","gists_url":"https://api.github.com/users/clark-t/gists{/gist_id}","starred_url":"https://api.github.com/users/clark-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clark-t/subscriptions","organizations_url":"https://api.github.com/users/clark-t/orgs","repos_url":"https://api.github.com/users/clark-t/repos","events_url":"https://api.github.com/users/clark-t/events{/privacy}","received_events_url":"https://api.github.com/users/clark-t/received_events","type":"User","site_admin":false},"assignees":[{"login":"clark-t","id":9402832,"node_id":"MDQ6VXNlcjk0MDI4MzI=","avatar_url":"https://avatars0.githubusercontent.com/u/9402832?v=4","gravatar_id":"","url":"https://api.github.com/users/clark-t","html_url":"https://github.com/clark-t","followers_url":"https://api.github.com/users/clark-t/followers","following_url":"https://api.github.com/users/clark-t/following{/other_user}","gists_url":"https://api.github.com/users/clark-t/gists{/gist_id}","starred_url":"https://api.github.com/users/clark-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clark-t/subscriptions","organizations_url":"https://api.github.com/users/clark-t/orgs","repos_url":"https://api.github.com/users/clark-t/repos","events_url":"https://api.github.com/users/clark-t/events{/privacy}","received_events_url":"https://api.github.com/users/clark-t/received_events","type":"User","site_admin":false},{"login":"yenshih","id":14069488,"node_id":"MDQ6VXNlcjE0MDY5NDg4","avatar_url":"https://avatars3.githubusercontent.com/u/14069488?v=4","gravatar_id":"","url":"https://api.github.com/users/yenshih","html_url":"https://github.com/yenshih","followers_url":"https://api.github.com/users/yenshih/followers","following_url":"https://api.github.com/users/yenshih/following{/other_user}","gists_url":"https://api.github.com/users/yenshih/gists{/gist_id}","starred_url":"https://api.github.com/users/yenshih/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yenshih/subscriptions","organizations_url":"https://api.github.com/users/yenshih/orgs","repos_url":"https://api.github.com/users/yenshih/repos","events_url":"https://api.github.com/users/yenshih/events{/privacy}","received_events_url":"https://api.github.com/users/yenshih/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2018-10-29T11:30:23Z","updated_at":"2018-11-06T07:54:59Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"**要解决什么问题**\r\n目前部分 MIP 组件存在依赖关系，比如 mip-list 依赖 mip-mustache，需要 mip-mustache 先加载完成之后再去加载 mip-list。简单通过 script 标签的书写顺序能解决问题，但明显不够优雅，也不利于各种资源加载优化方案的展开。因此需要在组件代码中新增配置，去显式声明组件依赖关系，由 MIP 核心去读取配置文件，控制组件的加载顺序。\r\n\r\n**描述一下你理想中的解决方案**\r\n在组件文件夹下新增 `meta.json` 文件，需要定义 `deps` 字段。如 mip-list 依赖 mip-mustache，那么对应的 meta.json 为：\r\n\r\n```json\r\n{\r\n  \"deps\": [\r\n    \"mip-mustache\"\r\n  ]\r\n}\r\n```\r\n\r\n在编译 mip-list 的时候，将生成类似的代码：\r\n\r\n```javascript\r\n(window.MIP = window.MIP || []).push({\r\n  name: 'mip-list',\r\n  func: function () {/* 组件代码 */},\r\n  deps: ['mip-mustache']\r\n})\r\n```\r\n\r\n然后修改 MIP.push() 方法去读取 deps 来控制组件的加载顺序。\r\n"},"comment":{"url":"https://api.github.com/repos/mipengine/mip2/issues/comments/436161740","html_url":"https://github.com/mipengine/mip2/issues/327#issuecomment-436161740","issue_url":"https://api.github.com/repos/mipengine/mip2/issues/327","id":436161740,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNjE2MTc0MA==","user":{"login":"Espoir-L","id":25815613,"node_id":"MDQ6VXNlcjI1ODE1NjEz","avatar_url":"https://avatars1.githubusercontent.com/u/25815613?v=4","gravatar_id":"","url":"https://api.github.com/users/Espoir-L","html_url":"https://github.com/Espoir-L","followers_url":"https://api.github.com/users/Espoir-L/followers","following_url":"https://api.github.com/users/Espoir-L/following{/other_user}","gists_url":"https://api.github.com/users/Espoir-L/gists{/gist_id}","starred_url":"https://api.github.com/users/Espoir-L/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Espoir-L/subscriptions","organizations_url":"https://api.github.com/users/Espoir-L/orgs","repos_url":"https://api.github.com/users/Espoir-L/repos","events_url":"https://api.github.com/users/Espoir-L/events{/privacy}","received_events_url":"https://api.github.com/users/Espoir-L/received_events","type":"User","site_admin":false},"created_at":"2018-11-06T07:54:59Z","updated_at":"2018-11-06T07:54:59Z","author_association":"MEMBER","body":"这个方法在小说的场景里会存在性能上的问题，因此需要核心代码提供可以监听组件之间是否注册成功的事件回调，以便进行业务代码的编写"}}
{"actor":{"display_login":"Espoir-L"}}