function createPolyfillsLoaderCode(cfg, polyfills) {
    if (!polyfills || polyfills.length === 0) {
        return { loadPolyfillsCode: '', generatedFiles: [] };
    }
    const generatedFiles = [];
    let loadPolyfillsCode = '  var polyfills = [];';
    polyfills.forEach(polyfill => {
        let loadScript = `loadScript('./${relativePolyfillPath(polyfill.path, cfg)}')`;
        if (polyfill.initializer) {
            loadScript += `.then(function () { ${polyfill.initializer} })`;
        }
        const loadPolyfillCode = `polyfills.push(${loadScript});`;
        if (polyfill.test) {
            loadPolyfillsCode += `if (${polyfill.test}) { ${loadPolyfillCode} }`;
        }
        else {
            loadPolyfillsCode += `${loadPolyfillCode}`;
        }
        generatedFiles.push({
            type: polyfill.type,
            path: polyfill.path,
            content: polyfill.content,
        });
    });
    return { loadPolyfillsCode, generatedFiles };
}
/**
 * Creates code which loads the configured polyfills
 */
Creates code which loads the configured polyfills
Creates code which loads the configured polyfills
function createPolyfillsLoaderCode(cfg, polyfills) {
    if (!polyfills || polyfills.length === 0) {
        return { loadPolyfillsCode: '', generatedFiles: [] };
    }
    const generatedFiles = [];
    let loadPolyfillsCode = '  var polyfills = [];';
    polyfills.forEach(polyfill => {
        let loadScript = `loadScript('./${relativePolyfillPath(polyfill.path, cfg)}')`;
        if (polyfill.initializer) {
            loadScript += `.then(function () { ${polyfill.initializer} })`;
        }
        const loadPolyfillCode = `polyfills.push(${loadScript});`;
        if (polyfill.test) {
            loadPolyfillsCode += `if (${polyfill.test}) { ${loadPolyfillCode} }`;
        }
        else {
            loadPolyfillsCode += `${loadPolyfillCode}`;
        }
        generatedFiles.push({
            type: polyfill.type,
            path: polyfill.path,
            content: polyfill.content,
        });
    });
    return { loadPolyfillsCode, generatedFiles };
}
function createPolyfillsLoaderCode ( cfg , polyfills ) { if ( ! polyfills || polyfills . length === 0 ) { return { loadPolyfillsCode : '' , generatedFiles : [ ] } ; } const generatedFiles = [ ] ; let loadPolyfillsCode = '  var polyfills = [];' ; polyfills . forEach ( polyfill => { let loadScript = ` ${ relativePolyfillPath ( polyfill . path , cfg ) } ` ; if ( polyfill . initializer ) { loadScript += ` ${ polyfill . initializer } ` ; } const loadPolyfillCode = ` ${ loadScript } ` ; if ( polyfill . test ) { loadPolyfillsCode += ` ${ polyfill . test } ${ loadPolyfillCode } ` ; } else { loadPolyfillsCode += ` ${ loadPolyfillCode } ` ; } generatedFiles . push ( { type : polyfill . type , path : polyfill . path , content : polyfill . content , } ) ; } ) ; return { loadPolyfillsCode , generatedFiles } ; }
Creates code which loads the configured polyfills
Creates code which loads the configured polyfills