perf: cache polyfills on-demand (#1954)
* perf: cache polyfills on-demand * fix: actually apply the name
This commit is contained in:
parent
2ecd8a39a9
commit
9cf8f8b516
|
@ -17,6 +17,10 @@ const ON_DEMAND_CACHE = [
|
||||||
{
|
{
|
||||||
regex: /traineddata\.gz/,
|
regex: /traineddata\.gz/,
|
||||||
cache: ASSETS
|
cache: ASSETS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
regex: /\$polyfill\$/,
|
||||||
|
cache: WEBPACK_ASSETS
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -35,6 +39,7 @@ 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('tesseract-core.wasm')) // cache on-demand
|
.filter(filename => !filename.includes('tesseract-core.wasm')) // cache on-demand
|
||||||
.filter(filename => !filename.includes('LICENSE')) // don't bother with license files
|
.filter(filename => !filename.includes('LICENSE')) // don't bother with license files
|
||||||
|
.filter(filename => !filename.includes('$polyfill$')) // polyfills are cached dynamically
|
||||||
|
|
||||||
// `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
|
||||||
|
|
|
@ -14,9 +14,8 @@ const urlRegex = require('../src/routes/_utils/urlRegexSource.js')()
|
||||||
const output = Object.assign(config.client.output(), {
|
const output = Object.assign(config.client.output(), {
|
||||||
// enables HMR in workers
|
// enables HMR in workers
|
||||||
globalObject: 'this',
|
globalObject: 'this',
|
||||||
// Zeit does not like filenames with "$" in them, so just keep things simple
|
filename: dev ? '[hash]/[id].js' : '[id].[contenthash].[name].js',
|
||||||
filename: dev ? '[hash]/[id].js' : '[id].[contenthash].js',
|
chunkFilename: dev ? '[hash]/[id].js' : '[id].[contenthash].[name].js'
|
||||||
chunkFilename: dev ? '[hash]/[id].js' : '[id].[contenthash].js'
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const emojiPickerI18n = LOCALE !== DEFAULT_LOCALE &&
|
const emojiPickerI18n = LOCALE !== DEFAULT_LOCALE &&
|
||||||
|
@ -93,8 +92,7 @@ module.exports = {
|
||||||
chunks: 'async',
|
chunks: 'async',
|
||||||
minSize: 5000,
|
minSize: 5000,
|
||||||
maxAsyncRequests: Infinity,
|
maxAsyncRequests: Infinity,
|
||||||
maxInitialRequests: Infinity,
|
maxInitialRequests: Infinity
|
||||||
name: false // these chunk names can be annoyingly long
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
Loading…
Reference in a new issue