From 56de531b6f9f120fc640184a0f048752aa49501c Mon Sep 17 00:00:00 2001 From: Valerii Gusev Date: Sat, 28 Jul 2018 20:20:10 +0200 Subject: [PATCH] Fix `Unexpected token <` error By default skipWaiting parameter is set to true, allowing newly registered service worker to bypass the `waiting` state, so all out of date cache entries from the previous service worker will be deleted. Because of async dynamic module loading we don't want that to happen, keeping a way of loading old chunks. The downside of removing skipWaiting is that newly deployed service worker code and caches won't become active until all existing tabs that have an older version of that service worker are closed, but that actually sounds we want exactly this behaviour. Related to https://github.com/GoogleChromeLabs/sw-precache/issues/180#issuecomment-248386760 --- packages/react-scripts/config/webpack.config.prod.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 6a296b169b5..66338654ff1 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -349,6 +349,9 @@ module.exports = { navigateFallbackWhitelist: [/^(?!\/__).*/], // Don't precache sourcemaps (they're large) and build asset manifest: staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], + // we are relying on older cached resources to be available throughout the page's lifetime + // because of async module loading + skipWaiting: false, }), // Moment.js is an extremely popular library that bundles large locale files // by default due to how Webpack interprets its code. This is a practical