build/lib/treeshaking.js
function discoverAndReadFiles(options) {
    const FILES = {};
    const in_queue = Object.create(null);
    const queue = [];
    const enqueue = (moduleId) => {
        if (in_queue[moduleId]) {
            return;
        }
        in_queue[moduleId] = true;
        queue.push(moduleId);
    };
    options.entryPoints.forEach((entryPoint) => enqueue(entryPoint));
    while (queue.length > 0) {
        const moduleId = queue.shift();
        const dts_filename = path.join(options.sourcesRoot, moduleId + '.d.ts');
        if (fs.existsSync(dts_filename)) {
            const dts_filecontents = fs.readFileSync(dts_filename).toString();
            FILES[`${moduleId}.d.ts`] = dts_filecontents;
            continue;
        }
        const js_filename = path.join(options.sourcesRoot, moduleId + '.js');
        if (fs.existsSync(js_filename)) {
            // This is an import for a .js file, so ignore it...
            continue;
        }
        let ts_filename;
        if (options.redirects[moduleId]) {
            ts_filename = path.join(options.sourcesRoot, options.redirects[moduleId] + '.ts');
        }
        else {
            ts_filename = path.join(options.sourcesRoot, moduleId + '.ts');
        }
        const ts_filecontents = fs.readFileSync(ts_filename).toString();
        const info = ts.preProcessFile(ts_filecontents);
        for (let i = info.importedFiles.length - 1; i >= 0; i--) {
            const importedFileName = info.importedFiles[i].fileName;
            if (options.importIgnorePattern.test(importedFileName)) {
                // Ignore vs/css! imports
                continue;
            }
            let importedModuleId = importedFileName;
            if (/(^\.\/)|(^\.\.\/)/.test(importedModuleId)) {
                importedModuleId = path.join(path.dirname(moduleId), importedModuleId);
            }
            enqueue(importedModuleId);
        }
        FILES[`${moduleId}.ts`] = ts_filecontents;
    }
    return FILES;
}
function discoverAndReadFiles(options) {
    const FILES = {};
    const in_queue = Object.create(null);
    const queue = [];
    const enqueue = (moduleId) => {
        if (in_queue[moduleId]) {
            return;
        }
        in_queue[moduleId] = true;
        queue.push(moduleId);
    };
    options.entryPoints.forEach((entryPoint) => enqueue(entryPoint));
    while (queue.length > 0) {
        const moduleId = queue.shift();
        const dts_filename = path.join(options.sourcesRoot, moduleId + '.d.ts');
        if (fs.existsSync(dts_filename)) {
            const dts_filecontents = fs.readFileSync(dts_filename).toString();
            FILES[`${moduleId}.d.ts`] = dts_filecontents;
            continue;
        }
        const js_filename = path.join(options.sourcesRoot, moduleId + '.js');
        if (fs.existsSync(js_filename)) {
            // This is an import for a .js file, so ignore it...
            continue;
        }
        let ts_filename;
        if (options.redirects[moduleId]) {
            ts_filename = path.join(options.sourcesRoot, options.redirects[moduleId] + '.ts');
        }
        else {
            ts_filename = path.join(options.sourcesRoot, moduleId + '.ts');
        }
        const ts_filecontents = fs.readFileSync(ts_filename).toString();
        const info = ts.preProcessFile(ts_filecontents);
        for (let i = info.importedFiles.length - 1; i >= 0; i--) {
            const importedFileName = info.importedFiles[i].fileName;
            if (options.importIgnorePattern.test(importedFileName)) {
                // Ignore vs/css! imports
                continue;
            }
            let importedModuleId = importedFileName;
            if (/(^\.\/)|(^\.\.\/)/.test(importedModuleId)) {
                importedModuleId = path.join(path.dirname(moduleId), importedModuleId);
            }
            enqueue(importedModuleId);
        }
        FILES[`${moduleId}.ts`] = ts_filecontents;
    }
    return FILES;
}
function discoverAndReadFiles ( options ) { const FILES = { } ; const in_queue = Object . create ( null ) ; const queue = [ ] ; const enqueue = ( moduleId ) => { if ( in_queue [ moduleId ] ) { return ; } in_queue [ moduleId ] = true ; queue . push ( moduleId ) ; } ; options . entryPoints . forEach ( ( entryPoint ) => enqueue ( entryPoint ) ) ; while ( queue . length > 0 ) { const moduleId = queue . shift ( ) ; const dts_filename = path . join ( options . sourcesRoot , moduleId + '.d.ts' ) ; if ( fs . existsSync ( dts_filename ) ) { const dts_filecontents = fs . readFileSync ( dts_filename ) . toString ( ) ; FILES [ ` ${ moduleId } ` ] = dts_filecontents ; continue ; } const js_filename = path . join ( options . sourcesRoot , moduleId + '.js' ) ; if ( fs . existsSync ( js_filename ) ) { // This is an import for a .js file, so ignore it... continue ; } let ts_filename ; if ( options . redirects [ moduleId ] ) { ts_filename = path . join ( options . sourcesRoot , options . redirects [ moduleId ] + '.ts' ) ; } else { ts_filename = path . join ( options . sourcesRoot , moduleId + '.ts' ) ; } const ts_filecontents = fs . readFileSync ( ts_filename ) . toString ( ) ; const info = ts . preProcessFile ( ts_filecontents ) ; for ( let i = info . importedFiles . length - 1 ; i >= 0 ; i -- ) { const importedFileName = info . importedFiles [ i ] . fileName ; if ( options . importIgnorePattern . test ( importedFileName ) ) { // Ignore vs/css! imports continue ; } let importedModuleId = importedFileName ; if ( / (^\.\/)|(^\.\.\/) / . test ( importedModuleId ) ) { importedModuleId = path . join ( path . dirname ( moduleId ) , importedModuleId ) ; } enqueue ( importedModuleId ) ; } FILES [ ` ${ moduleId } ` ] = ts_filecontents ; } return FILES ; }
Read imports and follow them until all files have been handled
Read imports and follow them until all files have been handled