{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/2304","labels_url":"https://api.github.com/repos/angular/angular/issues/2304/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/2304/comments","events_url":"https://api.github.com/repos/angular/angular/issues/2304/events","html_url":"https://github.com/angular/angular/issues/2304","id":84271587,"number":2304,"title":"Can we hide ReflectionCapabilities as an implementation detail?","user":{"login":"kegluneq","id":613610,"avatar_url":"https://avatars.githubusercontent.com/u/613610?v=3","gravatar_id":"","url":"https://api.github.com/users/kegluneq","html_url":"https://github.com/kegluneq","followers_url":"https://api.github.com/users/kegluneq/followers","following_url":"https://api.github.com/users/kegluneq/following{/other_user}","gists_url":"https://api.github.com/users/kegluneq/gists{/gist_id}","starred_url":"https://api.github.com/users/kegluneq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kegluneq/subscriptions","organizations_url":"https://api.github.com/users/kegluneq/orgs","repos_url":"https://api.github.com/users/kegluneq/repos","events_url":"https://api.github.com/users/kegluneq/events{/privacy}","received_events_url":"https://api.github.com/users/kegluneq/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/angular/angular/labels/action:%20Design","name":"action: Design","color":"006b75"},{"url":"https://api.github.com/repos/angular/angular/labels/comp:%20dart-transformer","name":"comp: dart-transformer","color":"c7def8"},{"url":"https://api.github.com/repos/angular/angular/labels/effort:%20hour","name":"effort: hour","color":"bfe5bf"},{"url":"https://api.github.com/repos/angular/angular/labels/P3:%20important","name":"P3: important","color":"fef2c0"},{"url":"https://api.github.com/repos/angular/angular/labels/type:%20RFC%20/%20discussion%20/%20question","name":"type: RFC / discussion / question","color":"EEEEEE"}],"state":"open","locked":false,"assignee":{"login":"mhevery","id":111951,"avatar_url":"https://avatars.githubusercontent.com/u/111951?v=3","gravatar_id":"","url":"https://api.github.com/users/mhevery","html_url":"https://github.com/mhevery","followers_url":"https://api.github.com/users/mhevery/followers","following_url":"https://api.github.com/users/mhevery/following{/other_user}","gists_url":"https://api.github.com/users/mhevery/gists{/gist_id}","starred_url":"https://api.github.com/users/mhevery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhevery/subscriptions","organizations_url":"https://api.github.com/users/mhevery/orgs","repos_url":"https://api.github.com/users/mhevery/repos","events_url":"https://api.github.com/users/mhevery/events{/privacy}","received_events_url":"https://api.github.com/users/mhevery/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/angular/angular/milestones/35","html_url":"https://github.com/angular/angular/milestones/M10","labels_url":"https://api.github.com/repos/angular/angular/milestones/35/labels","id":1136489,"number":35,"title":"M10","description":"","creator":{"login":"mhevery","id":111951,"avatar_url":"https://avatars.githubusercontent.com/u/111951?v=3","gravatar_id":"","url":"https://api.github.com/users/mhevery","html_url":"https://github.com/mhevery","followers_url":"https://api.github.com/users/mhevery/followers","following_url":"https://api.github.com/users/mhevery/following{/other_user}","gists_url":"https://api.github.com/users/mhevery/gists{/gist_id}","starred_url":"https://api.github.com/users/mhevery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhevery/subscriptions","organizations_url":"https://api.github.com/users/mhevery/orgs","repos_url":"https://api.github.com/users/mhevery/repos","events_url":"https://api.github.com/users/mhevery/events{/privacy}","received_events_url":"https://api.github.com/users/mhevery/received_events","type":"User","site_admin":false},"open_issues":37,"closed_issues":11,"state":"open","created_at":"2015-05-27T17:26:34Z","updated_at":"2015-06-03T20:18:43Z","due_on":"2015-06-08T07:00:00Z","closed_at":null},"comments":4,"created_at":"2015-06-03T00:02:23Z","updated_at":"2015-06-03T20:45:59Z","closed_at":null,"body":"cc: @yjbanov , @kwalrath \r\n\r\nI've been talking with folks recently about the need for the user to instantiate `ReflectionCapabilities`. I remember we spoke about this a while back and that you had some concerns about hiding this from the user completely, but I can't remember the specifics and was hoping to get them documented since I get this question a lot.\r\n\r\nThe proposal is:\r\n\r\nIn application.ts\r\n```\r\nexport function bootstrap(...) {\r\n  if (reflector.reflectionCapabilities == null) {\r\n    reflector.reflectionCapabilities = new ReflectionCapabilities();\r\n  }\r\n  bootstrapStatic(...);\r\n}\r\n\r\nexport function bootstrapStatic(...) {\r\n  // The current implementation of `bootstrap`\r\n}\r\n```\r\n\r\nThe user writes main.dart:\r\n```\r\nvoid main() {\r\n  bootstrap(MyComponent);\r\n}\r\n```\r\nwhich we then rewrite to:\r\n```\r\nimport 'main.ng_deps.dart' as i0;\r\nvoid main() {\r\n  i0.initReflector();bootstrapStatic(MyComponent);\r\n}\r\n```\r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/108611055","html_url":"https://github.com/angular/angular/issues/2304#issuecomment-108611055","issue_url":"https://api.github.com/repos/angular/angular/issues/2304","id":108611055,"user":{"login":"kegluneq","id":613610,"avatar_url":"https://avatars.githubusercontent.com/u/613610?v=3","gravatar_id":"","url":"https://api.github.com/users/kegluneq","html_url":"https://github.com/kegluneq","followers_url":"https://api.github.com/users/kegluneq/followers","following_url":"https://api.github.com/users/kegluneq/following{/other_user}","gists_url":"https://api.github.com/users/kegluneq/gists{/gist_id}","starred_url":"https://api.github.com/users/kegluneq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kegluneq/subscriptions","organizations_url":"https://api.github.com/users/kegluneq/orgs","repos_url":"https://api.github.com/users/kegluneq/repos","events_url":"https://api.github.com/users/kegluneq/events{/privacy}","received_events_url":"https://api.github.com/users/kegluneq/received_events","type":"User","site_admin":false},"created_at":"2015-06-03T20:45:59Z","updated_at":"2015-06-03T20:45:59Z","body":"Discussed this offline & here's what we determined:\r\n\r\n# TL;DR:\r\n\r\nWe can hide `ReflectionCapabilities` as an implementation detail.\r\n\r\n# Former Situation\r\n\r\nPreviously, bindings provided to the `Injector` were immediately resolved. This meant that providing a binding to the `Injector` depended on `ReflectionCapabilities` having been instantiated. Since we needed to support providing bindings to the injector prior to calling `bootstrap`, we couldn't tie `ReflectionCapabilities` instantiation to `bootstrap`\r\n\r\n# Current Situation\r\n\r\nResolution of bindings is now deferred until later in the process, so we no longer need `ReflectionCapabilities` until the user calls `bootstrap`, meaning we can hide `ReflectionCapabilities` as an implementation detail.\r\n\r\n# Plan going forward\r\n\r\n`bootstrap` will now automatically create `ReflectionCapabilities`. This requires `import`ing `reflection_capabilities.dart` and therefore transitively `import`ing `dart:mirrors` in the file that defines `bootstrap`. The transformer will need to remove this `import` to avoid mirrors.\r\n\r\n## Option 1\r\n\r\nProvide a special import for Dart `bootstrap`ing that creates `ReflectionCapabilities`, then calls into the standard `bootstrap`. The transformer rewrites the special import to the standard import, removing our transitive import of `dart:mirrors`.\r\n\r\n### Pros\r\n\r\nThis allows us to rewrite user code instead of Angular library code, which is slightly simpler from a transformer standpoint.\r\n\r\n### Cons\r\n\r\nThis leads to a situation where the user has to remember to import the special version of `bootstrap` rather than the standard one. If the user forgets, development will fail due to lack of reflective access and the transformer will fail to insert calls to its generated code.\r\n\r\n## Option 2\r\n\r\nRewrite Angular code directly, removing the `import` of `reflection_capabilities.dart` from the library that provides `bootstrap` and adding the call to the transformer's generated code.\r\n\r\n### Pros\r\n\r\nUse of `bootstrap` looks the same in Js & Dart code.\r\n\r\n### Cons\r\n\r\nSlightly more difficult transformer implementation.\r\n\r\n\r\nGiven these pros & cons, I'd prefer to go for Option 2. I'll speak with @jakemac53 about how they do this in polymer and see if it can inform our implementation."}}