@@ -92,25 +92,31 @@ async function writeEntry({path, title, hasLoader, hasStyleSheet, hasCompatibili
9292 await writeFile ( d , html ( platform , title , hasLoader , hasStyleSheet , hasCompatibilityCheck ) ) ;
9393}
9494
95- async function bundleHTML ( { platforms, debug} ) {
96- const promises = [ ] ;
97- const enabledPlatforms = Object . values ( PLATFORM ) . filter ( ( platform ) => platform !== PLATFORM . API && platforms [ platform ] ) ;
98- for ( const entry of htmlEntries ) {
99- if ( entry . platforms && ! entry . platforms . some ( ( platform ) => platforms [ platform ] ) ) {
100- continue ;
101- }
102- for ( const platform of enabledPlatforms ) {
103- if ( entry . platforms === undefined || entry . platforms . includes ( platform ) ) {
104- promises . push ( writeEntry ( entry , { debug, platform} ) ) ;
95+ /**
96+ * @param {HTMLEntry[] } htmlEntries
97+ * @returns {ReturnType<typeof createTask> }
98+ */
99+ export function createBundleHTMLTask ( htmlEntries ) {
100+ const bundleHTML = async ( { platforms, debug} ) => {
101+ const promises = [ ] ;
102+ const enabledPlatforms = Object . values ( PLATFORM ) . filter ( ( platform ) => platform !== PLATFORM . API && platforms [ platform ] ) ;
103+ for ( const entry of htmlEntries ) {
104+ if ( entry . platforms && ! entry . platforms . some ( ( platform ) => platforms [ platform ] ) ) {
105+ continue ;
106+ }
107+ for ( const platform of enabledPlatforms ) {
108+ if ( entry . platforms === undefined || entry . platforms . includes ( platform ) ) {
109+ promises . push ( writeEntry ( entry , { debug, platform} ) ) ;
110+ }
105111 }
106112 }
107- }
108- await Promise . all ( promises ) ;
109- }
113+ await Promise . all ( promises ) ;
114+ } ;
110115
111- const bundleHTMLTask = createTask (
112- 'bundle-html' ,
113- bundleHTML ,
114- ) ;
116+ return createTask (
117+ 'bundle-html' ,
118+ bundleHTML ,
119+ ) ;
120+ }
115121
116- export default bundleHTMLTask ;
122+ export default createBundleHTMLTask ( htmlEntries ) ;
0 commit comments