diff --git a/packages/bazel/src/modify_tsconfig.js b/packages/bazel/src/modify_tsconfig.js index 7eee260c2f..b93fd97636 100644 --- a/packages/bazel/src/modify_tsconfig.js +++ b/packages/bazel/src/modify_tsconfig.js @@ -23,13 +23,19 @@ function main(args) { const data = JSON.parse(fs.readFileSync(input, {encoding: 'utf-8'})); data['compilerOptions']['target'] = 'es5'; data['bazelOptions']['es5Mode'] = true; - data['compilerOptions']['outDir'] = path.join(data['compilerOptions']['outDir'], newRoot); + data['compilerOptions']['outDir'] = path.posix.join(data['compilerOptions']['outDir'], newRoot); if (data['angularCompilerOptions']) { + // Relative path to the execroot that refers to the directory for the ES5 output files. + const newOutputBase = path.posix.join(binDir, newRoot); // Don't enable tsickle's closure conversions data['angularCompilerOptions']['annotateForClosureCompiler'] = false; + // Note: It's important that the "expectedOut" is only modified in a way that still + // keeps posix normalized paths. Otherwise this could cause unexpected behavior because + // ngc-wrapped is expecting POSIX paths and the TypeScript Bazel rules by default only pass + // POSIX paths as well. data['angularCompilerOptions']['expectedOut'] = data['angularCompilerOptions']['expectedOut'].map( - f => f.replace(/\.closure\.js$/, '.js').replace(binDir, path.join(binDir, newRoot))); + f => f.replace(/\.closure\.js$/, '.js').replace(binDir, newOutputBase)); } fs.writeFileSync(output, JSON.stringify(data)); }