@@ -168,6 +168,8 @@ export const adjustProbabilities = (
168168 }
169169
170170 if (
171+ // don't queue until we have initialized the preloader
172+ base != null &&
171173 bundle . $state$ < BundleImportState_Preload &&
172174 bundle . $inverseProbability$ < config . $invPreloadProbability$
173175 ) {
@@ -192,7 +194,6 @@ export const adjustProbabilities = (
192194 // it's already at max probability
193195 continue ;
194196 }
195- const prevAdjust = dep . $factor$ ;
196197 /**
197198 * The chance that a dep won't be loaded is 1-(the chance that the dep will be loaded)*(the
198199 * chance that the current bundle will be loaded).
@@ -213,13 +214,14 @@ export const adjustProbabilities = (
213214 newInverseProbability = Math . min ( 0.01 , 1 - dep . $importProbability$ ) ;
214215 } else {
215216 const newInverseImportProbability = 1 - dep . $importProbability$ * probability ;
217+ /** We need to undo the previous adjustment */
218+ const prevAdjust = dep . $factor$ ;
216219 const factor = newInverseImportProbability / prevAdjust ;
217220 // limit organic probability to 98%
218221 newInverseProbability = Math . max ( 0.02 , depBundle . $inverseProbability$ * factor ) ;
219222 dep . $factor$ = factor ;
220223 }
221224
222- /** We need to undo the previous adjustment */
223225 adjustProbabilities ( depBundle , newInverseProbability , seen ) ;
224226 }
225227 }
@@ -228,7 +230,7 @@ export const adjustProbabilities = (
228230export const handleBundle = ( name : string , inverseProbability : number ) => {
229231 const bundle = getBundle ( name ) ;
230232 if ( bundle && bundle . $inverseProbability$ > inverseProbability ) {
231- adjustProbabilities ( bundle , inverseProbability / bundle . $inverseProbability$ ) ;
233+ adjustProbabilities ( bundle , inverseProbability ) ;
232234 }
233235} ;
234236
0 commit comments