From 9728dce0485a222825feca15e322bea5654dcee8 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 22 Dec 2017 15:12:32 -0800 Subject: [PATCH] fix(bazel): Give correct module names for ES6 output (#21320) Fixes #21022 PR Close #21320 --- packages/bazel/src/ngc-wrapped/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/bazel/src/ngc-wrapped/index.ts b/packages/bazel/src/ngc-wrapped/index.ts index 48b07e765f..4db274dd41 100644 --- a/packages/bazel/src/ngc-wrapped/index.ts +++ b/packages/bazel/src/ngc-wrapped/index.ts @@ -27,6 +27,8 @@ const ALLOW_NON_HERMETIC_READS = true; // Note: We compile the content of node_modules with plain ngc command line. const ALL_DEPS_COMPILED_WITH_BAZEL = false; +const NODE_MODULES = 'node_modules/'; + export function main(args) { if (runAsWorker(args)) { runWorkerLoop(runOneBuild); @@ -175,7 +177,11 @@ export function compile({allowNonHermeticReads, allDepsCompiledWithBazel = true, ngHost.amdModuleName) { return ngHost.amdModuleName({ fileName: importedFilePath } as ts.SourceFile); } - return relativeToRootDirs(importedFilePath, compilerOpts.rootDirs).replace(EXT, ''); + const result = relativeToRootDirs(importedFilePath, compilerOpts.rootDirs).replace(EXT, ''); + if (result.startsWith(NODE_MODULES)) { + return result.substr(NODE_MODULES.length); + } + return bazelOpts.workspaceName + '/' + result; }; ngHost.toSummaryFileName = (fileName: string, referringSrcFileName: string) => relativeToRootDirs(fileName, compilerOpts.rootDirs).replace(EXT, '');