Skip to content

Commit 748d41f

Browse files
committed
version 0.1.0
refactor service worker to try to get index.html from network first, then fall back to the cached version
1 parent 4f48da2 commit 748d41f

File tree

7 files changed

+279
-286
lines changed

7 files changed

+279
-286
lines changed

README.md

+5-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Ember Service Worker Index
22

3-
**[ember-service-worker-index is built and maintained by DockYard, contact us for expert Ember.js consulting](https://dockyard.com/ember-consulting)**.
4-
53
_An Ember Service Worker plugin that caches an Ember app's index file_
64

75
## F#$& my assets aren't updating in development mode
@@ -12,7 +10,7 @@ menu in the Chrome devtools.
1210
## Installation
1311

1412
```
15-
ember install ember-service-worker-index
13+
ember install ember-service-worker-index-fallback
1614
```
1715

1816
## Configuration
@@ -28,6 +26,9 @@ module.exports = function(defaults) {
2826
// Where the location of your index file is at, defaults to `index.html`
2927
location: 'app-shell.html',
3028

29+
// time in milliseconds that fetching index.html from network may take before the cached version is served
30+
requestTimeout: 500,
31+
3132
// Bypass esw-index and don't serve cached index file for matching URLs
3233
excludeScope: [/\/non-ember-app(\/.*)?$/, /\/another-app(\/.*)?$/],
3334

@@ -50,21 +51,9 @@ module.exports = function(defaults) {
5051
## Authors
5152

5253
* [Marten Schilstra](http://twitter.com/martndemus)
54+
* [st-h](https://github.com/st-h)
5355

5456
## Versioning
5557

5658
This library follows [Semantic Versioning](http://semver.org)
5759

58-
## Want to help?
59-
60-
Please do! We are always looking to improve this library. Please see our
61-
[Contribution Guidelines](https://github.com/dockyard/ember-service-worker-index/blob/master/CONTRIBUTING.md)
62-
on how to properly submit issues and pull requests.
63-
64-
## Legal
65-
66-
[DockYard](http://dockyard.com/), Inc. © 2016
67-
68-
[@dockyard](http://twitter.com/dockyard)
69-
70-
[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var Config = require('./lib/config');
55
var mergeTrees = require('broccoli-merge-trees');
66

77
module.exports = {
8-
name: 'ember-service-worker-index',
8+
name: 'ember-service-worker-index-fallback',
99

1010
included: function(app) {
1111
this._super.included && this._super.included.apply(this, arguments);

lib/config.js

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module.exports = class Config extends Plugin {
2727
let location = options.location || "index.html";
2828
let excludeScope = options.excludeScope || [];
2929
let includeScope = options.includeScope || [];
30+
let requestTimeout = options.requestTimeout || 500;
3031

3132
let fileLocation = location;
3233
if (fileLocation[fileLocation.length - 1] === "/") {
@@ -42,6 +43,7 @@ module.exports = class Config extends Plugin {
4243
module += `export const INDEX_HTML_PATH = '${location}';\n`;
4344
module += `export const INDEX_EXCLUDE_SCOPE = [${excludeScope}];\n`;
4445
module += `export const INDEX_INCLUDE_SCOPE = [${includeScope}];\n`;
46+
module += `export const REQUEST_TIMEOUT = [${requestTimeout}];\n`;
4547
module += `self.INDEX_FILE_HASH = '${hash}';\n`;
4648

4749
fs.writeFileSync(path.join(this.outputPath, "config.js"), module);

package-lock.json

-249
This file was deleted.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "ember-service-worker-index",
3-
"version": "0.7.0",
2+
"name": "ember-service-worker-index-fallback",
3+
"version": "0.8.0",
44
"description": "An Ember Service Worker plugin that caches the index.html file",
55
"directories": {
66
"doc": "doc",
77
"test": "tests"
88
},
9-
"repository": "https://github.com/DockYard/ember-service-worker-index",
9+
"repository": "https://github.com/st-h/ember-service-worker-index-fallback",
1010
"engines": {
1111
"node": ">= 6.0.0"
1212
},
@@ -18,7 +18,7 @@
1818
],
1919
"dependencies": {
2020
"broccoli-merge-trees": "^3.0.1",
21-
"broccoli-plugin": "^1.3.1"
21+
"broccoli-plugin": "^2.1.0"
2222
},
2323
"ember-addon": {
2424
"configPath": "tests/dummy/config"

0 commit comments

Comments
 (0)