MCPcopy Create free account
hub / github.com/SAP/ui5-builder / writePreloadFunction

Method writePreloadFunction

lib/lbt/bundle/Builder.js:309–344  ·  view source on GitHub ↗
(section)

Source from the content-addressed store, hash-verified

307 }
308
309 async writePreloadFunction(section) {
310 const outW = this.outW;
311
312 outW.ensureNewLine();
313
314 const sequence = section.modules.slice();
315
316 this.beforeWriteFunctionPreloadSection(sequence);
317
318 await this.rewriteAMDModules(sequence);
319 if ( sequence.length > 0 ) {
320 this.writeWithSourceMap(`sap.ui.require.preload({\n`);
321 let i = 0;
322 for ( const module of sequence ) {
323 const resource = await this.pool.findResourceWithInfo(module);
324 if ( resource != null ) {
325 if ( i>0 ) {
326 outW.writeln(",");
327 }
328 outW.write(`\t"${module.toString()}":`);
329 outW.startSegment(module);
330 await this.writePreloadModule(module, resource.info, resource);
331 const compressedSize = outW.endSegment();
332 log.verbose(` ${module} (${resource.info != null ? resource.info.size : -1},${compressedSize})`);
333 i++;
334 } else {
335 log.error(` Could not find module ${module}`);
336 }
337 }
338
339 if ( i > 0 ) {
340 outW.writeln();
341 }
342 outW.write(this.generateAfterPreloads(section));
343 }
344 }
345
346 beforeWriteFunctionPreloadSection(sequence) {
347 // simple version: just sort alphabetically

Callers 1

addSectionMethod · 0.95

Calls 12

rewriteAMDModulesMethod · 0.95
writeWithSourceMapMethod · 0.95
writePreloadModuleMethod · 0.95
generateAfterPreloadsMethod · 0.95
ensureNewLineMethod · 0.80
findResourceWithInfoMethod · 0.80
writelnMethod · 0.80
writeMethod · 0.80
startSegmentMethod · 0.80
endSegmentMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected