| 43 | }; |
| 44 | |
| 45 | const checkCache = function(invalidate) { |
| 46 | if (!cache) return; |
| 47 | const idHash = {}; |
| 48 | const missing = {}; |
| 49 | cache.modules.forEach(mod => { |
| 50 | const moduleId = mod.id; |
| 51 | const isRollupHelper = (moduleId[0] === '\u0000'); |
| 52 | if (isRollupHelper) { |
| 53 | // Ignore as injected rollup module |
| 54 | return null; |
| 55 | } |
| 56 | if (!fs.existsSync(moduleId)) { |
| 57 | grunt.log.error(`Cache missing file: ${moduleId.replace(cwd, '')}`); |
| 58 | missing[moduleId] = true; |
| 59 | return false; |
| 60 | } |
| 61 | if (invalidate && invalidate.includes(moduleId)) { |
| 62 | grunt.log.ok(`Cache skipping file: ${moduleId.replace(cwd, '')}`); |
| 63 | return false; |
| 64 | } |
| 65 | idHash[moduleId] = mod; |
| 66 | return true; |
| 67 | }); |
| 68 | if (Object.keys(missing).length) { |
| 69 | cache = null; |
| 70 | return; |
| 71 | } |
| 72 | cache.modules = Object.values(idHash); |
| 73 | }; |
| 74 | |
| 75 | const saveCache = async (cachePath, basePath, bundleCache) => { |
| 76 | if (!isDisableCache) { |