Compare commits

..

3 Commits

Author SHA1 Message Date
Rich-Harris
2758382c68 -> v0.10.5 2018-04-06 18:32:44 -07:00
Rich Harris
dd7f1ff99c Merge pull request #231 from sveltejs/fix-missing-service-worker
fix missing service worker
2018-04-06 21:31:53 -04:00
Rich-Harris
45142cd037 fix missing service worker 2018-04-06 14:44:50 -07:00
4 changed files with 13 additions and 3 deletions

View File

@@ -1,5 +1,9 @@
# sapper changelog
## 0.10.5
* Fix missing service worker ([#231](https://github.com/sveltejs/sapper/pull/231))
## 0.10.4
* Upgrade chokidar, this time with a fix ([#227](https://github.com/sveltejs/sapper/pull/227))

View File

@@ -1,6 +1,6 @@
{
"name": "sapper",
"version": "0.10.4",
"version": "0.10.5",
"description": "Military-grade apps, engineered by Svelte",
"main": "dist/middleware.ts.js",
"bin": {

View File

@@ -245,11 +245,11 @@ function get_route_handler(chunks: Record<string, string>, routes: RouteObject[]
`baseUrl: "${req.baseUrl}"`,
serialized.preloaded && `preloaded: ${serialized.preloaded}`,
serialized.store && `store: ${serialized.store}`
].filter(Boolean).join(',')}}`
].filter(Boolean).join(',')}};`;
const has_service_worker = fs.existsSync(path.join(locations.dest(), 'service-worker.js'));
if (has_service_worker) {
`if ('serviceWorker' in navigator) navigator.serviceWorker.register('${req.baseUrl}/service-worker.js')`
inline_script += `if ('serviceWorker' in navigator) navigator.serviceWorker.register('${req.baseUrl}/service-worker.js');`;
}
const page = template()

View File

@@ -559,6 +559,12 @@ function run({ mode, basepath = '' }) {
assert.equal(title, 'woohoo!');
});
});
it('includes service worker', () => {
return nightmare.goto(base).page.html().then(html => {
assert.ok(html.indexOf('service-worker.js') !== -1);
});
});
});
describe('headers', () => {