{"action":"created","comment":{"url":"https://api.github.com/repos/Polymer/polymer-build/pulls/comments/72324594","id":72324594,"diff_hunk":"@@ -0,0 +1,153 @@\n+/**\n+ * @license\n+ * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n+ * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n+ * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n+ * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n+ * Code distributed by Google as part of the polymer project is also\n+ * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n+ */\n+\n+import {writeFile} from 'fs';\n+import * as path from 'path';\n+import * as logging from 'plylog';\n+import {PolymerProject} from './polymer-project';\n+import {DepsIndex} from './analyzer';\n+const swPrecache = require('sw-precache');\n+\n+// non-ES compatible modules\n+let logger = logging.getLogger('polymer-build.service-worker');\n+\n+export interface SWConfig {\n+  cacheId?: string;\n+  directoryIndex?: string;\n+  dynamicUrlToDependencies?: {\n+    [property: string]: string[]\n+  };\n+  handleFetch?: boolean;\n+  ignoreUrlParametersMatching?: RegExp[];\n+  importScripts?: string[];\n+  logger?: Function;\n+  maximumFileSizeToCacheInBytes?: number;\n+  navigateFallback?: string;\n+  navigateFallbackWhitelist?: RegExp[];\n+  replacePrefix?: string;\n+  runtimeCaching?: {\n+    urlPattern: RegExp;\n+    handler: string;\n+    options?: {\n+      cache: {\n+        maxEntries: number;\n+        name: string;\n+      };\n+    };\n+  }[];\n+  staticFileGlobs?: string[];\n+  stripPrefix?: string;\n+  templateFilePath?: string;\n+  verbose?: boolean;\n+}\n+\n+export interface AddServiceWorkerOptions {\n+  project: PolymerProject;\n+  buildRoot: string;\n+  bundled?: boolean;","path":"src/service-worker.ts","position":54,"original_position":54,"commit_id":"8759e69d35fcdda1322ee0c3990eb8bc688e9a46","original_commit_id":"8759e69d35fcdda1322ee0c3990eb8bc688e9a46","user":{"login":"FredKSchott","id":622227,"avatar_url":"https://avatars.githubusercontent.com/u/622227?v=3","gravatar_id":"","url":"https://api.github.com/users/FredKSchott","html_url":"https://github.com/FredKSchott","followers_url":"https://api.github.com/users/FredKSchott/followers","following_url":"https://api.github.com/users/FredKSchott/following{/other_user}","gists_url":"https://api.github.com/users/FredKSchott/gists{/gist_id}","starred_url":"https://api.github.com/users/FredKSchott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FredKSchott/subscriptions","organizations_url":"https://api.github.com/users/FredKSchott/orgs","repos_url":"https://api.github.com/users/FredKSchott/repos","events_url":"https://api.github.com/users/FredKSchott/events{/privacy}","received_events_url":"https://api.github.com/users/FredKSchott/received_events","type":"User","site_admin":false},"body":"+1 point for the build stream as its own custom type :)\r\n\r\nWe could split the two methods and add `addBundledServiceWorker()`. `generateServiceWorker()` could remain as-is so that we don't need to split that as well.\r\n\r\nWe could also make `getPrecachedAssets()`/`getBundledPrecachedAssets()` public and have the gulpfile author properly call those themselves, and then send the result as an option to `generateServiceWorker()` instead.\r\n\r\nI don't love it either but it's a small nit for me vs. our other options. Let me know if you think this is a big enough problem that we should address it now.","created_at":"2016-07-26T19:56:04Z","updated_at":"2016-07-26T19:56:04Z","html_url":"https://github.com/Polymer/polymer-build/pull/7#discussion_r72324594","pull_request_url":"https://api.github.com/repos/Polymer/polymer-build/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/Polymer/polymer-build/pulls/comments/72324594"},"html":{"href":"https://github.com/Polymer/polymer-build/pull/7#discussion_r72324594"},"pull_request":{"href":"https://api.github.com/repos/Polymer/polymer-build/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/Polymer/polymer-build/pulls/7","id":78773628,"html_url":"https://github.com/Polymer/polymer-build/pull/7","diff_url":"https://github.com/Polymer/polymer-build/pull/7.diff","patch_url":"https://github.com/Polymer/polymer-build/pull/7.patch","issue_url":"https://api.github.com/repos/Polymer/polymer-build/issues/7","number":7,"state":"open","locked":false,"title":"Add ability to generate and write a service worker to disk","user":{"login":"FredKSchott","id":622227,"avatar_url":"https://avatars.githubusercontent.com/u/622227?v=3","gravatar_id":"","url":"https://api.github.com/users/FredKSchott","html_url":"https://github.com/FredKSchott","followers_url":"https://api.github.com/users/FredKSchott/followers","following_url":"https://api.github.com/users/FredKSchott/following{/other_user}","gists_url":"https://api.github.com/users/FredKSchott/gists{/gist_id}","starred_url":"https://api.github.com/users/FredKSchott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FredKSchott/subscriptions","organizations_url":"https://api.github.com/users/FredKSchott/orgs","repos_url":"https://api.github.com/users/FredKSchott/repos","events_url":"https://api.github.com/users/FredKSchott/events{/privacy}","received_events_url":"https://api.github.com/users/FredKSchott/received_events","type":"User","site_admin":false},"body":"It is now possible to add a service worker via the polymer-build library. Ex:\r\n\r\n```js\r\nexport {addServiceWorker} from 'polymer-build';\r\n\r\naddServiceWorker({\r\n  project: polymerProject,\r\n  buildRoot: 'build/unbundled',\r\n  swConfig: swConfig\r\n});\r\n```\r\n\r\nThis replaces the current code that was build specifically for the polymer-cli use-case, and allows custom configuration via the options object. It must be called after the build is finished, since the internal process relies on the exact files to exist on disk.\r\n\r\nSee test/gulpfile.js for usage.\r\n\r\n/cc @justinfagnani @robdodson \r\n","created_at":"2016-07-26T00:19:40Z","updated_at":"2016-07-26T19:56:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9e05fce32db021175b62f94f701dc0e85ddb997","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Polymer/polymer-build/pulls/7/commits","review_comments_url":"https://api.github.com/repos/Polymer/polymer-build/pulls/7/comments","review_comment_url":"https://api.github.com/repos/Polymer/polymer-build/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Polymer/polymer-build/issues/7/comments","statuses_url":"https://api.github.com/repos/Polymer/polymer-build/statuses/8759e69d35fcdda1322ee0c3990eb8bc688e9a46","head":{"label":"Polymer:add-service-worker","ref":"add-service-worker","sha":"8759e69d35fcdda1322ee0c3990eb8bc688e9a46","user":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":60874241,"name":"polymer-build","full_name":"Polymer/polymer-build","owner":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polymer/polymer-build","description":"A library of Gulp build tasks","fork":false,"url":"https://api.github.com/repos/Polymer/polymer-build","forks_url":"https://api.github.com/repos/Polymer/polymer-build/forks","keys_url":"https://api.github.com/repos/Polymer/polymer-build/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/polymer-build/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/polymer-build/teams","hooks_url":"https://api.github.com/repos/Polymer/polymer-build/hooks","issue_events_url":"https://api.github.com/repos/Polymer/polymer-build/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/polymer-build/events","assignees_url":"https://api.github.com/repos/Polymer/polymer-build/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/polymer-build/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/polymer-build/tags","blobs_url":"https://api.github.com/repos/Polymer/polymer-build/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/polymer-build/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/polymer-build/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/polymer-build/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/polymer-build/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/polymer-build/languages","stargazers_url":"https://api.github.com/repos/Polymer/polymer-build/stargazers","contributors_url":"https://api.github.com/repos/Polymer/polymer-build/contributors","subscribers_url":"https://api.github.com/repos/Polymer/polymer-build/subscribers","subscription_url":"https://api.github.com/repos/Polymer/polymer-build/subscription","commits_url":"https://api.github.com/repos/Polymer/polymer-build/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/polymer-build/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/polymer-build/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/polymer-build/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polymer/polymer-build/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/polymer-build/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/polymer-build/merges","archive_url":"https://api.github.com/repos/Polymer/polymer-build/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/polymer-build/downloads","issues_url":"https://api.github.com/repos/Polymer/polymer-build/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/polymer-build/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/polymer-build/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/polymer-build/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/polymer-build/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/polymer-build/releases{/id}","deployments_url":"https://api.github.com/repos/Polymer/polymer-build/deployments","created_at":"2016-06-10T20:14:04Z","updated_at":"2016-07-19T07:08:14Z","pushed_at":"2016-07-26T17:24:25Z","git_url":"git://github.com/Polymer/polymer-build.git","ssh_url":"git@github.com:Polymer/polymer-build.git","clone_url":"https://github.com/Polymer/polymer-build.git","svn_url":"https://github.com/Polymer/polymer-build","homepage":null,"size":19430,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"Polymer:master","ref":"master","sha":"5e8455172f73d76c9d7be7816f160b2e3d2c975b","user":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"repo":{"id":60874241,"name":"polymer-build","full_name":"Polymer/polymer-build","owner":{"login":"Polymer","id":2159051,"avatar_url":"https://avatars.githubusercontent.com/u/2159051?v=3","gravatar_id":"","url":"https://api.github.com/users/Polymer","html_url":"https://github.com/Polymer","followers_url":"https://api.github.com/users/Polymer/followers","following_url":"https://api.github.com/users/Polymer/following{/other_user}","gists_url":"https://api.github.com/users/Polymer/gists{/gist_id}","starred_url":"https://api.github.com/users/Polymer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Polymer/subscriptions","organizations_url":"https://api.github.com/users/Polymer/orgs","repos_url":"https://api.github.com/users/Polymer/repos","events_url":"https://api.github.com/users/Polymer/events{/privacy}","received_events_url":"https://api.github.com/users/Polymer/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Polymer/polymer-build","description":"A library of Gulp build tasks","fork":false,"url":"https://api.github.com/repos/Polymer/polymer-build","forks_url":"https://api.github.com/repos/Polymer/polymer-build/forks","keys_url":"https://api.github.com/repos/Polymer/polymer-build/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Polymer/polymer-build/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Polymer/polymer-build/teams","hooks_url":"https://api.github.com/repos/Polymer/polymer-build/hooks","issue_events_url":"https://api.github.com/repos/Polymer/polymer-build/issues/events{/number}","events_url":"https://api.github.com/repos/Polymer/polymer-build/events","assignees_url":"https://api.github.com/repos/Polymer/polymer-build/assignees{/user}","branches_url":"https://api.github.com/repos/Polymer/polymer-build/branches{/branch}","tags_url":"https://api.github.com/repos/Polymer/polymer-build/tags","blobs_url":"https://api.github.com/repos/Polymer/polymer-build/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Polymer/polymer-build/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Polymer/polymer-build/git/refs{/sha}","trees_url":"https://api.github.com/repos/Polymer/polymer-build/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Polymer/polymer-build/statuses/{sha}","languages_url":"https://api.github.com/repos/Polymer/polymer-build/languages","stargazers_url":"https://api.github.com/repos/Polymer/polymer-build/stargazers","contributors_url":"https://api.github.com/repos/Polymer/polymer-build/contributors","subscribers_url":"https://api.github.com/repos/Polymer/polymer-build/subscribers","subscription_url":"https://api.github.com/repos/Polymer/polymer-build/subscription","commits_url":"https://api.github.com/repos/Polymer/polymer-build/commits{/sha}","git_commits_url":"https://api.github.com/repos/Polymer/polymer-build/git/commits{/sha}","comments_url":"https://api.github.com/repos/Polymer/polymer-build/comments{/number}","issue_comment_url":"https://api.github.com/repos/Polymer/polymer-build/issues/comments{/number}","contents_url":"https://api.github.com/repos/Polymer/polymer-build/contents/{+path}","compare_url":"https://api.github.com/repos/Polymer/polymer-build/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Polymer/polymer-build/merges","archive_url":"https://api.github.com/repos/Polymer/polymer-build/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Polymer/polymer-build/downloads","issues_url":"https://api.github.com/repos/Polymer/polymer-build/issues{/number}","pulls_url":"https://api.github.com/repos/Polymer/polymer-build/pulls{/number}","milestones_url":"https://api.github.com/repos/Polymer/polymer-build/milestones{/number}","notifications_url":"https://api.github.com/repos/Polymer/polymer-build/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Polymer/polymer-build/labels{/name}","releases_url":"https://api.github.com/repos/Polymer/polymer-build/releases{/id}","deployments_url":"https://api.github.com/repos/Polymer/polymer-build/deployments","created_at":"2016-06-10T20:14:04Z","updated_at":"2016-07-19T07:08:14Z","pushed_at":"2016-07-26T17:24:25Z","git_url":"git://github.com/Polymer/polymer-build.git","ssh_url":"git@github.com:Polymer/polymer-build.git","clone_url":"https://github.com/Polymer/polymer-build.git","svn_url":"https://github.com/Polymer/polymer-build","homepage":null,"size":19430,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Polymer/polymer-build/pulls/7"},"html":{"href":"https://github.com/Polymer/polymer-build/pull/7"},"issue":{"href":"https://api.github.com/repos/Polymer/polymer-build/issues/7"},"comments":{"href":"https://api.github.com/repos/Polymer/polymer-build/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/Polymer/polymer-build/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/Polymer/polymer-build/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Polymer/polymer-build/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/Polymer/polymer-build/statuses/8759e69d35fcdda1322ee0c3990eb8bc688e9a46"}}}}
{"actor":{"display_login":"FredKSchott"}}