This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global $VERSION, $Cache, importScripts, WorkboxSW */ | |
importScripts('https://unpkg.com/workbox-sw@1.1.0/build/importScripts/workbox-sw.prod.v1.1.0.js'); | |
// Add app shell to the webpack-generated precache list | |
$Cache.precache.push({ url: 'sw-shell.html', revision: $VERSION }); | |
// Register precache list with Workbox | |
const workbox = new WorkboxSW({ handleFetch: true, skipWaiting: true, clientClaim: true }); | |
workbox.precache($Cache.precache); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Create a service worker for every locale to precache the locale bundle */ | |
const ServiceWorkerConfigs = locales.reduce((configs, locale) => { | |
return Object.assign(configs, { | |
[`mobile-${locale}`]: Object.assign({}, BaseConfig, { | |
template: path.join(__dirname, 'swTemplates/mobileBase.js'), | |
cache: { | |
template: path.join(__dirname, 'swTemplates/mobileCache.js'), | |
precache: [ | |
'vendor-mweb-.*\\.js$', | |
'entryChunk-mobile-.*\\.js$', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bundles = { | |
'vendor-mweb': [ | |
'app/mobile/polyfills.js', | |
'intl', | |
'normalizr', | |
'react-dom', | |
'react-redux', | |
'react-router-dom', | |
'react', | |
'redux' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a loader | |
const Closeup = () => import(/* webpackChunkName: "CloseupPage" */ 'app/mobile/routes/CloseupPage'); | |
// Register it to the route | |
route('/pin/:pinId', routes.Closeup, { name: 'Closeup' }), | |
// Render a react-router-v4 Route with the route bundle loader | |
<Route exact key="matched-route" path={path} render={matchProps => | |
<PageRoute | |
bundleLoader={loader} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Homefeed = createFeed({ | |
feedKey: 'homefeed', | |
resourceName: 'UserHomefeedResource', | |
resourceOptions: () => ({ | |
field_set_key: 'mobile_grid_item', | |
}), | |
pullToRefresh: true, | |
}); | |
const HomePage = (props: Props) => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Props = { | |
match: { params: { username: string } }, | |
resource: { fetching: boolean }, | |
user: User, | |
}; | |
export default withResource({ | |
name: 'UserResource', | |
key: 'resource', | |
options: ({ match }: Props) => ({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
<DeferredMount ssr /> | |
This component defers rendering of its children until after mounting, good | |
for below-the-fold content. If the content should be rendered syncronously | |
on the server you can set the `ssr` prop. If `ssr` is set to true, there | |
will be a client/server mismatch unless you can somehow determine that we | |
are hydrating from the server. | |
Is there a better way than the hack below? | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
caches: { | |
CACHE_V1: {} | |
}, | |
clients: [], | |
notifications: [], | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const makeServiceWorkerEnv = require('service-worker-mock'); | |
const Response = () => ({ clone: jest.fn() }); | |
const Request = () => ({ url: '/test' }); | |
describe('Service worker', () => { | |
beforeEach(() => { | |
Object.assign(global, makeServiceWorkerEnv()); | |
jest.resetModules(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const makeServiceWorkerEnv = require('service-worker-mock'); | |
describe('Service worker', () => { | |
beforeEach(() => { | |
Object.assign(global, makeServiceWorkerEnv()); | |
jest.resetModules(); | |
}); | |
it('should delete old caches on activate', async () => { | |
require('../sw.js'); |
NewerOlder