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
This commit is contained in:
parent
7ad6b0378c
commit
7d598801f0
|
@ -23,13 +23,19 @@ function main(args) {
|
||||||
const data = JSON.parse(fs.readFileSync(input, {encoding: 'utf-8'}));
|
const data = JSON.parse(fs.readFileSync(input, {encoding: 'utf-8'}));
|
||||||
data['compilerOptions']['target'] = 'es5';
|
data['compilerOptions']['target'] = 'es5';
|
||||||
data['bazelOptions']['es5Mode'] = true;
|
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']) {
|
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
|
// Don't enable tsickle's closure conversions
|
||||||
data['angularCompilerOptions']['annotateForClosureCompiler'] = false;
|
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'] =
|
||||||
data['angularCompilerOptions']['expectedOut'].map(
|
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));
|
fs.writeFileSync(output, JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue