Internal change.
PiperOrigin-RevId: 195808492
diff --git a/internal/tsc_wrapped/compiler_host.ts b/internal/tsc_wrapped/compiler_host.ts
index fa43a74..0de7918 100644
--- a/internal/tsc_wrapped/compiler_host.ts
+++ b/internal/tsc_wrapped/compiler_host.ts
@@ -33,6 +33,21 @@
return options as BazelTsOptions;
}
+function validateBazelOptions(bazelOpts: BazelOptions) {
+ if (!bazelOpts.isJsTranspilation) return;
+
+ if (bazelOpts.compilationTargetSrc &&
+ bazelOpts.compilationTargetSrc.length > 1) {
+ throw new Error("In JS transpilation mode, only one file can appear in " +
+ "bazelOptions.compilationTargetSrc.");
+ }
+
+ if (!bazelOpts.transpiledJsOutputFileName) {
+ throw new Error("In JS transpilation mode, transpiledJsOutputFileName " +
+ "must be specified in tsconfig.");
+ }
+}
+
const TS_EXT = /(\.d)?\.tsx?$/;
/**
@@ -94,6 +109,7 @@
this.directoryExists = delegate.directoryExists.bind(delegate);
}
+ validateBazelOptions(bazelOpts);
this.googmodule = bazelOpts.googmodule;
this.es5Mode = bazelOpts.es5Mode;
this.prelude = bazelOpts.prelude;
@@ -344,8 +360,7 @@
fileName = this.flattenOutDir(fileName);
if (this.bazelOpts.isJsTranspilation) {
- // Write transpiled JS to *.dev_es5.js.
- fileName = fileName.replace(/\.js$/, '.dev_es5.js');
+ fileName = this.bazelOpts.transpiledJsOutputFileName!;
} else if (!this.bazelOpts.es5Mode) {
// Write ES6 transpiled files to *.closure.js.
if (this.bazelOpts.locale) {
diff --git a/internal/tsc_wrapped/tsconfig.ts b/internal/tsc_wrapped/tsconfig.ts
index c861c06..10c3215 100644
--- a/internal/tsc_wrapped/tsconfig.ts
+++ b/internal/tsc_wrapped/tsconfig.ts
@@ -139,9 +139,17 @@
moduleRoot?: string;
/**
- * If true, indicates that this job is transpiling JS sources.
+ * If true, indicates that this job is transpiling JS sources. If true, only
+ * one file can appear in compilationTargetSrc, and transpiledJsOutputFileName
+ * must be set.
*/
isJsTranspilation?: boolean;
+
+ /**
+ * The path where the file containing the JS transpiled output should
+ * be written. Ignored if isJsTranspilation is false.
+ */
+ transpiledJsOutputFileName?: string;
}
export interface ParsedTsConfig {