Skip to content

Commit

Permalink
Don't bust cache just because there's a new file
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Mar 27, 2020
1 parent 9d87fe8 commit 9b7c9d6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions build-system/compile/pre-closure-babel.js
Expand Up @@ -21,7 +21,6 @@ const fs = require('fs');
const globby = require('globby');
const gulpBabel = require('gulp-babel');
const gulpCache = require('gulp-cache');
const path = require('path');
const through = require('through2');
const {BABEL_SRC_GLOBS, THIRD_PARTY_TRANSFORM_GLOBS} = require('./sources');

Expand Down Expand Up @@ -51,7 +50,6 @@ function preClosureBabel() {
fs.readFileSync(require.resolve('./build.conf.js')).toString('hex'),
fs.readFileSync('./babel.config.js').toString('hex'),
JSON.stringify(argv),
...filesToTransform,
].join(':');

const babelPlugins = conf.plugins({
Expand Down Expand Up @@ -94,7 +92,12 @@ function preClosureBabel() {
const cache = gulpCache(through.obj(transform), {
name: 'amp-pre-closure-babel',
key(file) {
return `${file.path}:${salt}:${file.contents.toString('hex')}`;
return [
file.path,
filesToTransform.includes(file.relative),
salt,
file.contents.toString('hex'),
].join(':');
},
});
return cache;
Expand Down

0 comments on commit 9b7c9d6

Please sign in to comment.