Disable Terser Cache When Using Flying Shuttle (#7168)

This commit is contained in:
Joe Haddad 2019-04-26 21:47:57 +09:00 committed by GitHub
parent 6f0e795f9b
commit 3daa473e6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View file

@ -73,7 +73,7 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, d
const terserPluginConfig = {
parallel: true,
sourceMap: false,
cache: true,
cache: !selectivePageBuilding,
cpus: config.experimental.cpus,
distDir: distDir
}

View file

@ -12,8 +12,10 @@ const writeFileP = promisify(writeFile)
const readFileP = promisify(readFile)
export default class TaskRunner {
constructor(distDir, cpus) {
mkdirp.sync((this.cacheDir = join(distDir, 'cache', 'next-minifier')))
constructor({ distDir, cpus, cache }) {
if (cache) {
mkdirp.sync((this.cacheDir = join(distDir, 'cache', 'next-minifier')))
}
// In some cases cpus() returns undefined
// https://github.com/nodejs/node/issues/19022
@ -68,7 +70,7 @@ export default class TaskRunner {
}
tasks.forEach((task, index) => {
const cachePath = join(this.cacheDir, task.cacheKey)
const cachePath = this.cacheDir && join(this.cacheDir, task.cacheKey)
const enqueue = () => {
this.boundWorkers(task, (error, data) => {

View file

@ -129,7 +129,11 @@ export class TerserPlugin {
apply(compiler) {
const optimizeFn = (compilation, chunks, callback) => {
const taskRunner = new TaskRunner(this.distDir, this.cpus)
const taskRunner = new TaskRunner({
distDir: this.distDir,
cpus: this.cpus,
cache: this.options.cache,
})
const processedAssets = new WeakSet()
const tasks = []
@ -285,7 +289,7 @@ export class TerserPlugin {
template.hooks.hashForChunk.tap(plugin, hash => {
// Terser version
// Has to be updated when options change too
hash.update('3.17.0');
hash.update('3.17.0')
return hash
})
}