@@ -18,6 +18,7 @@ import getDependencyName from './utils/get-dependency-name';
1818import DependencyNotFoundError from '../errors/dependency-not-found-error' ;
1919import ModuleNotFoundError from '../errors/module-not-found-error' ;
2020import TestRunner from './tests/jest-lite' ;
21+ import dependenciesToQuery from '../npm/dependencies-to-query' ;
2122
2223type Externals = {
2324 [ name : string ] : string ,
@@ -682,6 +683,20 @@ export default class Manager {
682683 this . hardReload = true ;
683684 }
684685
686+ getDependencyQuery ( ) {
687+ if ( ! this . manifest || ! this . manifest . dependencies ) {
688+ return '';
689+ }
690+
691+ const normalizedDependencies = { } ;
692+
693+ this . manifest . dependencies . forEach ( dep => {
694+ normalizedDependencies [ dep . name ] = dep . version ;
695+ } ) ;
696+
697+ return dependenciesToQuery ( normalizedDependencies ) ;
698+ }
699+
685700 /**
686701 * Generate a JSON structure out of this manager that can be used to load
687702 * the manager later on. This is useful for faster initial loading.
@@ -697,11 +712,14 @@ export default class Manager {
697712 } ) ;
698713 } ) ;
699714
715+ const dependenciesQuery = this . getDependencyQuery ( ) ;
716+
700717 await localforage . setItem ( this . id , {
701718 transpiledModules : serializedTModules ,
702719 cachedPaths : this . cachedPaths ,
703720 version : VERSION ,
704721 configurations : this . configurations ,
722+ dependenciesQuery,
705723 } ) ;
706724 } catch ( e ) {
707725 if ( process . env . NODE_ENV === 'development' ) {
@@ -721,16 +739,21 @@ export default class Manager {
721739 cachedPaths ,
722740 version ,
723741 configurations ,
742+ dependenciesQuery ,
724743 } : {
725744 transpiledModules : { [ id : string ] : SerializedTranspiledModule } ,
726745 cachedPaths : { [ path : string ] : string } ,
727746 version : string ,
728747 configurations : Object ,
748+ dependenciesQuery : string ,
729749 } = data ;
730750
731751 // Only use the cache if the cached version was cached with the same
732- // version of the compiler
733- if ( version === VERSION ) {
752+ // version of the compiler and dependencies haven't changed
753+ if (
754+ version === VERSION &&
755+ dependenciesQuery === this . getDependencyQuery ( )
756+ ) {
734757 this . cachedPaths = cachedPaths ;
735758 this . configurations = configurations ;
736759
0 commit comments