From 7887d2c8488992afb8da8aa34a9c2de45e7f15a5 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 15 Feb 2019 20:31:22 -0800 Subject: [PATCH] fix: remove deferred polyfill caching (#999) As of #998 we can no longer rely on JS files containing , let alone . This was a nice idea, but it's just not maintainable anymore nor does it provide a huge benefit. --- src/service-worker.js | 8 -------- webpack/client.config.js | 14 ++++++++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/service-worker.js b/src/service-worker.js index 0f041b4a..9e148c65 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -24,7 +24,6 @@ const assets = __assets__ // also contains '/index.html' for some reason const webpackAssets = __shell__ .filter(filename => !filename.endsWith('.map')) // don't bother with sourcemaps - .filter(filename => !filename.includes('$polyfill$')) // polyfills are cached on-demand // `routes` is an array of `{ pattern: RegExp }` objects that // match the pages in your src @@ -100,13 +99,6 @@ self.addEventListener('fetch', event => { return response } } - // for polyfills, cache them on-the-fly - if (url.pathname.includes('$polyfill$')) { - let response = await fetch(req) - // cache asynchronously, don't wait - caches.open(WEBPACK_ASSETS).then(cache => cache.put(req, response)) - return response.clone() - } } // for everything else, go network-only diff --git a/webpack/client.config.js b/webpack/client.config.js index df5bfa83..071a4ebf 100644 --- a/webpack/client.config.js +++ b/webpack/client.config.js @@ -6,15 +6,17 @@ const terser = require('./terser.config') const CircularDependencyPlugin = require('circular-dependency-plugin') const { mode, dev, resolve } = require('./shared.config') -const output = config.client.output() - -// Zeit does not like filenames with "$" in them, so just keep things simple -output.filename = '[hash]/[id].js' -output.chunkFilename = '[hash]/[id].js' +const output = Object.assign(config.client.output(), { + // enables HMR in workers + globalObject: 'this', + // Zeit does not like filenames with "$" in them, so just keep things simple + filename: '[hash]/[id].js', + chunkFilename: '[hash]/[id].js' +}) module.exports = { entry: config.client.entry(), - output: Object.assign(output, { globalObject: 'this' }), // enables HMR in workers + output, resolve, mode, module: {