From 7d598801f079ff1a14bd77638e95119ce388ef92 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 20 Nov 2018 21:06:17 +0100 Subject: [PATCH] fix(bazel): ng_package not generating UMD bundles on windows (#27200) * Fixes that `ng_package` does not work generate UMD bundles on Windows because the `esm5/` files are not written to the output directory. This is because `rootDirs` and `rootDir` are posix paths and cause invalid relative paths when mixed with Windows backslash paths. PR Close #27200 --- packages/bazel/src/modify_tsconfig.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)); }