File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,11 @@ export default class ExportMapBuilder {
92
92
93
93
exportMap . mtime = stats . mtime ;
94
94
95
- exportCache . set ( cacheKey , exportMap ) ;
95
+ // If the visitor keys were not populated, then we shouldn't save anything to the cache,
96
+ // since the parse results may not be reliable.
97
+ if ( exportMap . visitorKeys ) {
98
+ exportCache . set ( cacheKey , exportMap ) ;
99
+ }
96
100
return exportMap ;
97
101
}
98
102
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ describe('ExportMap', function () {
21
21
} ,
22
22
{
23
23
settings : { } ,
24
- parserPath : 'babel-eslint' ,
24
+ parserPath : require . resolve ( 'babel-eslint' ) ,
25
25
} ,
26
26
) ;
27
27
@@ -41,6 +41,15 @@ describe('ExportMap', function () {
41
41
. to . exist . and . equal ( ExportMapBuilder . get ( './named-exports' , fakeContext ) ) ;
42
42
} ) ;
43
43
44
+ it ( 'does not return a cached copy if the parse does not yield a visitor keys' , function ( ) {
45
+ const mockContext = {
46
+ ...fakeContext ,
47
+ parserPath : 'not-real' ,
48
+ } ;
49
+ expect ( ExportMapBuilder . get ( './named-exports' , mockContext ) )
50
+ . to . exist . and . not . equal ( ExportMapBuilder . get ( './named-exports' , mockContext ) ) ;
51
+ } ) ;
52
+
44
53
it ( 'does not return a cached copy after modification' , ( done ) => {
45
54
const firstAccess = ExportMapBuilder . get ( './mutator' , fakeContext ) ;
46
55
expect ( firstAccess ) . to . exist ;
You can’t perform that action at this time.
0 commit comments