From d2707f14574bdfd4ea0c0ecf3d85383f6d54186a Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 1 Sep 2017 13:13:49 -0700 Subject: [PATCH] build: cleanup duplicated code now in @bazel/typescript (#19004) PR Close #19004 --- packages/bazel/src/ngc-wrapped/index.ts | 35 +------------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/packages/bazel/src/ngc-wrapped/index.ts b/packages/bazel/src/ngc-wrapped/index.ts index 08782fb7fa..1b5a3397ba 100644 --- a/packages/bazel/src/ngc-wrapped/index.ts +++ b/packages/bazel/src/ngc-wrapped/index.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import * as ng from '@angular/compiler-cli'; -import {CachedFileLoader, CompilerHost, FileCache, FileLoader, UncachedFileLoader, debug, parseTsconfig, runAsWorker, runWorkerLoop} from '@bazel/typescript'; +import {CachedFileLoader, CompilerHost, FileCache, FileLoader, UncachedFileLoader, constructManifest, debug, parseTsconfig, runAsWorker, runWorkerLoop} from '@bazel/typescript'; import * as fs from 'fs'; import * as path from 'path'; import * as tsickle from 'tsickle'; @@ -23,39 +23,6 @@ const NGC_NON_TS_INPUTS = // https://github.com/bazelbuild/rules_typescript/issues/28 const ALLOW_NON_HERMETIC_READS = true; -function topologicalSort( - result: tsickle.FileMap, current: string, modulesManifest: tsickle.ModulesManifest, - visiting: tsickle.FileMap) { - const referencedModules = modulesManifest.getReferencedModules(current); - if (!referencedModules) return; // not in the local set of sources. - for (const referencedModule of referencedModules) { - const referencedFileName = modulesManifest.getFileNameFromModule(referencedModule); - if (!referencedFileName) continue; // Ambient modules. - if (!result[referencedFileName]) { - if (visiting[referencedFileName]) { - const path = current + ' -> ' + Object.keys(visiting).join(' -> '); - throw new Error('Cyclical dependency between files:\n' + path); - } - visiting[referencedFileName] = true; - topologicalSort(result, referencedFileName, modulesManifest, visiting); - delete visiting[referencedFileName]; - } - } - result[current] = true; -} -// TODO(alexeagle): move to tsc-wrapped in third_party so it's shared -export function constructManifest( - modulesManifest: tsickle.ModulesManifest, - host: {flattenOutDir: (f: string) => string}): string { - const result: tsickle.FileMap = {}; - for (const file of modulesManifest.fileNames) { - topologicalSort(result, file, modulesManifest, {}); - } - - // NB: The object literal maintains insertion order. - return Object.keys(result).map(fn => host.flattenOutDir(fn)).join('\n') + '\n'; -} - export function main(args) { if (runAsWorker(args)) { runWorkerLoop(runOneBuild);