{"action":"created","comment":{"url":"https://api.github.com/repos/angular/angular/pulls/comments/175299976","pull_request_review_id":104807730,"id":175299976,"diff_hunk":"@@ -0,0 +1,377 @@\n+/**\n+ * @license\n+ * Copyright Google Inc. All Rights Reserved.\n+ *\n+ * Use of this source code is governed by an MIT-style license that can be\n+ * found in the LICENSE file at https://angular.io/license\n+ */\n+\n+import {Component, Directive, NgModule, Pipe, PipeTransform, Type} from '../../../src/core';\n+import * as $r3$ from '../../../src/core_render3_private_export';\n+import {ComponentDef, DirectiveDef} from '../../../src/render3';\n+import {PipeDef} from '../../../src/render3/interfaces/definition';\n+\n+type $boolean$ = boolean;\n+type $TRUST_TYPE$ = any;\n+type $MyComponent$ = MyComponent;\n+type $MyApp$ = MyApp;\n+\n+/**\n+ * This spec demonstrates how component can respect locality in a backwards compatible way which\n+ * does not break tree shaking.\n+ *\n+ * Locality is important goal to the compiler because it allows tho compiler to translate each of","path":"packages/core/test/render3/compiler_canonical/local_selectors.ts","position":23,"original_position":23,"commit_id":"b08b2caffdd3144f5cc64954801dac4a8609352e","original_commit_id":"b08b2caffdd3144f5cc64954801dac4a8609352e","user":{"login":"mhevery","id":111951,"avatar_url":"https://avatars0.githubusercontent.com/u/111951?v=4","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},"body":"fixed","created_at":"2018-03-18T19:06:57Z","updated_at":"2018-03-18T19:06:57Z","html_url":"https://github.com/angular/angular/pull/22831#discussion_r175299976","pull_request_url":"https://api.github.com/repos/angular/angular/pulls/22831","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/comments/175299976"},"html":{"href":"https://github.com/angular/angular/pull/22831#discussion_r175299976"},"pull_request":{"href":"https://api.github.com/repos/angular/angular/pulls/22831"}},"in_reply_to_id":175242065},"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/22831","id":175655587,"html_url":"https://github.com/angular/angular/pull/22831","diff_url":"https://github.com/angular/angular/pull/22831.diff","patch_url":"https://github.com/angular/angular/pull/22831.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/22831","number":22831,"state":"open","locked":false,"title":"test(ivy): example of locality working with component selectors","user":{"login":"mhevery","id":111951,"avatar_url":"https://avatars0.githubusercontent.com/u/111951?v=4","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},"body":"This spec demonstrates how component can respect locality in a backwards compatible way which\r\ndoes not break tree shaking.\r\n\r\nLocality is important goal to the compiler because it allows tho compiler to translate each of\r\nthe Angular types (`@Component`, `@Directive`, `@Pipe`, `@NgModule`) in a way which does not\r\nrequire any information outside of what is directly available in the decorator. This allows\r\nsource to be compiled in an independent way. The consequence of this is simple compiler mental\r\nmodel, fast compiles, and publishing compiled code to NPM.\r\n\r\nTree shaking is important because we want to ensure that only symbols which are directly needed\r\nby the components are retained.\r\n\r\nThe proposal solves two problems:\r\n1. How to compile `@Component` without knowing what other components, directives or pipes are\r\n   active.\r\n2. Produce output which is tree shakable.\r\n\r\nGoal 1 is achieved by compiling `@Component` templates as if there were no other components,\r\ndirectives or pipes present. The resulting `ComponentDef` object than allows 'patching' of\r\ncomponent, directives, and pipes at a later point in time (before the first render). On first\r\nrender the Ivy render engine resolves the component, directives, and pipes. Subsequent renders\r\nare fast since the resolution has happened. The \"patching\" process is achieved by the\r\n`@NgModule`'s `defineNgModule` function. While this allows the code to run without any further\r\ntool chain it breaks tree shaking.\r\n\r\nGoal 2 is achieved by allowing build-optimizer to rearrange the `defineNgModule` calls such\r\nthat the information is moved to the specific components and the `defineNgModule` is removed.\r\nThis transformation allows the subsequent build tools to remove any unreferenced symbols.\r\n\r\nThe moving of definitions from `defineNgModule` to `defineComponent` needs to be done in a way\r\nwhich takes selectors into account. (Just because `@NgModule` declares component `Foo` does not\r\nmean that it is used in an application. Blindly applying `Foo` to all components would retain\r\nit even if no one used it.) For this reason the generated code contains pragmas for the\r\nbuild-optimizer which tell it how the code should be rearranged in tree-shakable way. The\r\nimportant thing to realize is that the rearranging has no semantic impact, it is purely an\r\noptimization operation to allow tree-shaker to do its job.\r\n\r\nWhen the build-optimizer looks to redistribute component, directive, and pipe references it\r\nneeds to know if the destination needs it. To do that build-optimizer needs to be able to\r\ncompare pipe names as well as execute selectors to see if any of the directives match a\r\ndestination. For this reason the generated code has pragmas in comments which communicate\r\nwhat pipe names are needed and which elements and attributes are in template to see if\r\nany of the potential directives match it. The pipe or directive is only added if the\r\nbuild-optimizer can determine that there has been a match.","created_at":"2018-03-16T21:59:19Z","updated_at":"2018-03-18T19:06:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a25557f27c2d4d821ae80e26e0fd851604d5ba2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":149476251,"url":"https://api.github.com/repos/angular/angular/labels/cla:%20yes","name":"cla: yes","color":"009800","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/22831/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/22831/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular/issues/22831/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/b08b2caffdd3144f5cc64954801dac4a8609352e","head":{"label":"mhevery:spec_selector_map","ref":"spec_selector_map","sha":"b08b2caffdd3144f5cc64954801dac4a8609352e","user":{"login":"mhevery","id":111951,"avatar_url":"https://avatars0.githubusercontent.com/u/111951?v=4","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},"repo":{"id":24658749,"name":"angular","full_name":"mhevery/angular","owner":{"login":"mhevery","id":111951,"avatar_url":"https://avatars0.githubusercontent.com/u/111951?v=4","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},"private":false,"html_url":"https://github.com/mhevery/angular","description":null,"fork":true,"url":"https://api.github.com/repos/mhevery/angular","forks_url":"https://api.github.com/repos/mhevery/angular/forks","keys_url":"https://api.github.com/repos/mhevery/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mhevery/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mhevery/angular/teams","hooks_url":"https://api.github.com/repos/mhevery/angular/hooks","issue_events_url":"https://api.github.com/repos/mhevery/angular/issues/events{/number}","events_url":"https://api.github.com/repos/mhevery/angular/events","assignees_url":"https://api.github.com/repos/mhevery/angular/assignees{/user}","branches_url":"https://api.github.com/repos/mhevery/angular/branches{/branch}","tags_url":"https://api.github.com/repos/mhevery/angular/tags","blobs_url":"https://api.github.com/repos/mhevery/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mhevery/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mhevery/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/mhevery/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mhevery/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/mhevery/angular/languages","stargazers_url":"https://api.github.com/repos/mhevery/angular/stargazers","contributors_url":"https://api.github.com/repos/mhevery/angular/contributors","subscribers_url":"https://api.github.com/repos/mhevery/angular/subscribers","subscription_url":"https://api.github.com/repos/mhevery/angular/subscription","commits_url":"https://api.github.com/repos/mhevery/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/mhevery/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/mhevery/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/mhevery/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/mhevery/angular/contents/{+path}","compare_url":"https://api.github.com/repos/mhevery/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mhevery/angular/merges","archive_url":"https://api.github.com/repos/mhevery/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mhevery/angular/downloads","issues_url":"https://api.github.com/repos/mhevery/angular/issues{/number}","pulls_url":"https://api.github.com/repos/mhevery/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/mhevery/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/mhevery/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mhevery/angular/labels{/name}","releases_url":"https://api.github.com/repos/mhevery/angular/releases{/id}","deployments_url":"https://api.github.com/repos/mhevery/angular/deployments","created_at":"2014-09-30T22:59:23Z","updated_at":"2018-03-13T20:35:30Z","pushed_at":"2018-03-18T19:01:38Z","git_url":"git://github.com/mhevery/angular.git","ssh_url":"git@github.com:mhevery/angular.git","clone_url":"https://github.com/mhevery/angular.git","svn_url":"https://github.com/mhevery/angular","homepage":null,"size":73566,"stargazers_count":10,"watchers_count":10,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":10,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"6ef9f2278f64697920df8ecaf79293a7eef7e0ab","user":{"login":"angular","id":139426,"avatar_url":"https://avatars3.githubusercontent.com/u/139426?v=4","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"name":"angular","full_name":"angular/angular","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars3.githubusercontent.com/u/139426?v=4","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular","description":"One framework. Mobile & desktop.","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","deployments_url":"https://api.github.com/repos/angular/angular/deployments","created_at":"2014-09-18T16:12:01Z","updated_at":"2018-03-18T18:58:10Z","pushed_at":"2018-03-18T19:01:40Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":"https://angular.io","size":76513,"stargazers_count":34144,"watchers_count":34144,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8374,"mirror_url":null,"archived":false,"open_issues_count":2235,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":8374,"open_issues":2235,"watchers":34144,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/22831"},"html":{"href":"https://github.com/angular/angular/pull/22831"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/22831"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/22831/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/22831/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/22831/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/b08b2caffdd3144f5cc64954801dac4a8609352e"}},"author_association":"OWNER"}}
{"actor":{"display_login":"mhevery"}}