chore: include transpilation mode in the compute cache hash (#11521)

This commit is contained in:
Pavel Feldman 2022-01-20 13:33:40 -08:00 committed by GitHub
parent 5a15d2cd4d
commit 50fa839e64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -239,6 +239,7 @@ export class Runner {
} }
// 4. Filter only // 4. Filter only
if (!list)
filterOnly(preprocessRoot); filterOnly(preprocessRoot);
// 5. Complain about clashing. // 5. Complain about clashing.

View File

@ -48,7 +48,7 @@ sourceMapSupport.install({
}); });
function calculateCachePath(content: string, filePath: string): string { function calculateCachePath(content: string, filePath: string): string {
const hash = crypto.createHash('sha1').update(content).update(filePath).update(String(version)).digest('hex'); const hash = crypto.createHash('sha1').update(process.env.PW_EXPERIMENTAL_TS_ESM ? 'esm' : 'no_esm').update(content).update(filePath).update(String(version)).digest('hex');
const fileName = path.basename(filePath, path.extname(filePath)).replace(/\W/g, '') + '_' + hash; const fileName = path.basename(filePath, path.extname(filePath)).replace(/\W/g, '') + '_' + hash;
return path.join(cacheDir, hash[0] + hash[1], fileName); return path.join(cacheDir, hash[0] + hash[1], fileName);
} }
@ -60,7 +60,7 @@ export function transformHook(code: string, filename: string, tsconfig: TsConfig
const codePath = cachePath + '.js'; const codePath = cachePath + '.js';
const sourceMapPath = cachePath + '.map'; const sourceMapPath = cachePath + '.map';
sourceMaps.set(filename, sourceMapPath); sourceMaps.set(filename, sourceMapPath);
if (fs.existsSync(codePath)) if (!process.env.PW_IGNORE_COMPILE_CACHE && fs.existsSync(codePath))
return fs.readFileSync(codePath, 'utf8'); return fs.readFileSync(codePath, 'utf8');
// We don't use any browserslist data, but babel checks it anyway. // We don't use any browserslist data, but babel checks it anyway.
// Silence the annoying warning. // Silence the annoying warning.