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.
This commit is contained in:
Nolan Lawson 2019-02-15 20:31:22 -08:00 committed by GitHub
parent 0d9dc7809c
commit 7887d2c848
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 14 deletions

View file

@ -24,7 +24,6 @@ const assets = __assets__
// also contains '/index.html' for some reason // also contains '/index.html' for some reason
const webpackAssets = __shell__ const webpackAssets = __shell__
.filter(filename => !filename.endsWith('.map')) // don't bother with sourcemaps .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 // `routes` is an array of `{ pattern: RegExp }` objects that
// match the pages in your src // match the pages in your src
@ -100,13 +99,6 @@ self.addEventListener('fetch', event => {
return response 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 // for everything else, go network-only

View file

@ -6,15 +6,17 @@ const terser = require('./terser.config')
const CircularDependencyPlugin = require('circular-dependency-plugin') const CircularDependencyPlugin = require('circular-dependency-plugin')
const { mode, dev, resolve } = require('./shared.config') const { mode, dev, resolve } = require('./shared.config')
const output = config.client.output() 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 // Zeit does not like filenames with "$" in them, so just keep things simple
output.filename = '[hash]/[id].js' filename: '[hash]/[id].js',
output.chunkFilename = '[hash]/[id].js' chunkFilename: '[hash]/[id].js'
})
module.exports = { module.exports = {
entry: config.client.entry(), entry: config.client.entry(),
output: Object.assign(output, { globalObject: 'this' }), // enables HMR in workers output,
resolve, resolve,
mode, mode,
module: { module: {