Skip to content

Commit

Permalink
cherry-pick(#11521): chore: include transpilation mode in the compute…
Browse files Browse the repository at this point in the history
… cache hash
  • Loading branch information
pavelfeldman committed Jan 20, 2022
1 parent e7a35c3 commit 6f857e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/playwright-test/src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sourceMapSupport.install({
});

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;
return path.join(cacheDir, hash[0] + hash[1], fileName);
}
Expand All @@ -60,7 +60,7 @@ export function transformHook(code: string, filename: string, tsconfig: TsConfig
const codePath = cachePath + '.js';
const sourceMapPath = cachePath + '.map';
sourceMaps.set(filename, sourceMapPath);
if (fs.existsSync(codePath))
if (!process.env.PW_IGNORE_COMPILE_CACHE && fs.existsSync(codePath))
return fs.readFileSync(codePath, 'utf8');
// We don't use any browserslist data, but babel checks it anyway.
// Silence the annoying warning.
Expand Down

0 comments on commit 6f857e0

Please sign in to comment.