@@ -32,11 +32,8 @@ type BundleImport = {
3232 $dynamicImports$ : string [ ] ;
3333} ;
3434let bundles : Map < string , BundleImport > | undefined ;
35- type WantedBundle = {
36- name : string ;
37- priority : boolean ;
38- } ;
39- const wantedBundles : Set < WantedBundle > = new Set ( ) ;
35+
36+ const wantedBundles = new Map < string , boolean > ( ) ;
4037
4138const parseBundleGraph = ( text : string , base : string ) => {
4239 try {
@@ -65,7 +62,7 @@ const parseBundleGraph = (text: string, base: string) => {
6562 $dynamicImports$ : dynamicImports ,
6663 } ) ;
6764 }
68- for ( const { name, priority } of wantedBundles ) {
65+ for ( const [ name , priority ] of wantedBundles ) {
6966 preload ( name , priority ) ;
7067 }
7168 wantedBundles . clear ( ) ;
@@ -75,6 +72,7 @@ const parseBundleGraph = (text: string, base: string) => {
7572 }
7673} ;
7774
75+ /** @internal */
7876export const loadBundleGraph = ( element : Element ) => {
7977 if ( typeof window === 'undefined' || bundlesP ) {
8078 return ;
@@ -137,9 +135,10 @@ const preloadBundle = (bundle: BundleImport, priority: boolean) => {
137135 bundle . $state$ = priority ? BundleImportState . Loading : BundleImportState . Low ;
138136} ;
139137
138+ /** @internal */
140139export const preload = ( name : string , priority : boolean ) => {
141140 if ( ! bundles ) {
142- wantedBundles . add ( { name, priority } ) ;
141+ wantedBundles . set ( name , priority || ! ! wantedBundles . get ( name ) ) ;
143142 return ;
144143 }
145144 const bundle = bundles . get ( name ) ;
0 commit comments