File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -489,8 +489,10 @@ function readThrough (
489489
490490 try {
491491 const output = getFile ( outputPath )
492- cache . outputs [ fileName ] = output
493- return output
492+ if ( isValidCacheContent ( output ) ) {
493+ cache . outputs [ fileName ] = output
494+ return output
495+ }
494496 } catch ( err ) { /* Ignore. */ }
495497
496498 const [ value , sourceMap ] = compile ( code , fileName , lineOffset )
@@ -536,6 +538,14 @@ function getCacheName (sourceCode: string, fileName: string) {
536538 . digest ( 'hex' )
537539}
538540
541+ /**
542+ * Ensure the given cached content is valid by sniffing for a base64 encoded '}'
543+ * at the end of the content, which should exist if there is a valid sourceMap present.
544+ */
545+ function isValidCacheContent ( content : string ) {
546+ return / (?: 9 | 0 = | Q = = ) $ / . test ( content . slice ( - 3 ) )
547+ }
548+
539549/**
540550 * Create a hash of the current configuration.
541551 */
You can’t perform that action at this time.
0 commit comments