File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 11import isNode from 'detect-node' ;
2- import LOADABLE_MARKS from './marks' ;
2+ import { loadMark } from './marks' ;
33
44let pending = [ ] ;
55
@@ -63,7 +63,7 @@ const toLoadable = (importFunction, autoImport = true) => {
6363 } ;
6464
6565 if ( mark ) {
66- mark . forEach ( subMark => LOADABLE_MARKS [ subMark ] = loadable )
66+ mark . forEach ( subMark => loadMark ( subMark , loadable ) )
6767 }
6868
6969 if ( isNode && autoImport ) {
Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ export const useMark = (stream, marks) => {
1010 }
1111} ;
1212
13+ export const loadMark = ( markId , loadable ) => {
14+ if ( ! LOADABLE_MARKS [ markId ] ) {
15+ LOADABLE_MARKS [ markId ] = [ ]
16+ }
17+ LOADABLE_MARKS [ markId ] . push ( loadable )
18+ } ;
19+
1320export const drainHydrateMarks = ( stream = 0 ) => {
1421 const used = Object . keys ( USED_MARKS [ stream ] || { } ) ;
1522 delete USED_MARKS [ stream ] ;
@@ -21,6 +28,7 @@ export const rehydrateMarks = (marks = false) => {
2128 return Promise . all (
2229 rehydrate
2330 . map ( mark => LOADABLE_MARKS [ mark ] )
31+ . reduce ( ( acc , loadable ) => [ ...acc , ...loadable ] , [ ] )
2432 . filter ( it => ! ! it )
2533 . map ( loadable => loadable . load ( ) )
2634 ) ;
You can’t perform that action at this time.
0 commit comments