Added environment variable to force experimental transformations.

This commit is contained in:
Ron Buckton 2016-03-21 11:54:10 -07:00
parent 3c344987de
commit 02ebfa5d11
4 changed files with 19 additions and 11 deletions

View file

@ -241,7 +241,6 @@ function concatenateFiles(destinationFile, sourceFiles) {
} }
var useDebugMode = true; var useDebugMode = true;
var useTransforms = process.env.USE_TRANSFORMS || false;
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node"); var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
var compilerFilename = "tsc.js"; var compilerFilename = "tsc.js";
var LKGCompiler = path.join(LKGDirectory, compilerFilename); var LKGCompiler = path.join(LKGDirectory, compilerFilename);
@ -309,8 +308,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
options += " --stripInternal" options += " --stripInternal"
} }
if (useBuiltCompiler && useTransforms) { if (useBuiltCompiler && Boolean(process.env.USE_TRANSFORMS)) {
options += " --experimentalTransforms" console.warn("\u001b[93mwarning: Found 'USE_TRANSFORMS' environment variable. Experimental transforms will be enabled by default.\u001b[0m");
} }
var cmd = host + " " + compilerPath + " " + options + " "; var cmd = host + " " + compilerPath + " " + options + " ";
@ -430,10 +429,6 @@ task("setDebugMode", function() {
useDebugMode = true; useDebugMode = true;
}); });
task("setTransforms", function() {
useTransforms = true;
});
task("configure-nightly", [configureNightlyJs], function() { task("configure-nightly", [configureNightlyJs], function() {
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs; var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs;
console.log(cmd); console.log(cmd);
@ -519,7 +514,7 @@ compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, cop
var i = content.lastIndexOf("\n"); var i = content.lastIndexOf("\n");
fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i)); fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i));
}); });
var serverFile = path.join(builtLocalDirectory, "tsserver.js"); var serverFile = path.join(builtLocalDirectory, "tsserver.js");
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true); compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);

View file

@ -994,6 +994,11 @@ namespace ts {
const start = new Date().getTime(); const start = new Date().getTime();
// TODO(rbuckton): remove USE_TRANSFORMS condition when we switch to transforms permenantly.
if (Boolean(sys.getEnvironmentVariable("USE_TRANSFORMS"))) {
options.experimentalTransforms = true;
}
const fileEmitter = options.experimentalTransforms ? printFiles : emitFiles; const fileEmitter = options.experimentalTransforms ? printFiles : emitFiles;
const emitResult = fileEmitter( const emitResult = fileEmitter(
emitResolver, emitResolver,

View file

@ -8,7 +8,6 @@ namespace ts {
args: string[]; args: string[];
newLine: string; newLine: string;
useCaseSensitiveFileNames: boolean; useCaseSensitiveFileNames: boolean;
/*@internal*/ developmentMode?: boolean;
write(s: string): void; write(s: string): void;
readFile(path: string, encoding?: string): string; readFile(path: string, encoding?: string): string;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void; writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
@ -23,6 +22,7 @@ namespace ts {
readDirectory(path: string, extension?: string, exclude?: string[]): string[]; readDirectory(path: string, extension?: string, exclude?: string[]): string[];
getMemoryUsage?(): number; getMemoryUsage?(): number;
exit(exitCode?: number): void; exit(exitCode?: number): void;
/*@internal*/ getEnvironmentVariable(name: string): string;
/*@internal*/ tryEnableSourceMapsForHost?(): void; /*@internal*/ tryEnableSourceMapsForHost?(): void;
} }
@ -213,6 +213,9 @@ namespace ts {
getCurrentDirectory() { getCurrentDirectory() {
return new ActiveXObject("WScript.Shell").CurrentDirectory; return new ActiveXObject("WScript.Shell").CurrentDirectory;
}, },
getEnvironmentVariable(name: string) {
return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings(`%${name}%`);
},
readDirectory, readDirectory,
exit(exitCode?: number): void { exit(exitCode?: number): void {
try { try {
@ -523,7 +526,6 @@ namespace ts {
args: process.argv.slice(2), args: process.argv.slice(2),
newLine: _os.EOL, newLine: _os.EOL,
useCaseSensitiveFileNames: useCaseSensitiveFileNames, useCaseSensitiveFileNames: useCaseSensitiveFileNames,
developmentMode: /^development$/i.test(String(process.env.NODE_ENV)),
write(s: string): void { write(s: string): void {
process.stdout.write(s); process.stdout.write(s);
}, },
@ -581,6 +583,9 @@ namespace ts {
getCurrentDirectory() { getCurrentDirectory() {
return process.cwd(); return process.cwd();
}, },
getEnvironmentVariable(name: string) {
return process.env[name] || "";
},
readDirectory, readDirectory,
getMemoryUsage() { getMemoryUsage() {
if (global.gc) { if (global.gc) {
@ -627,6 +632,9 @@ namespace ts {
createDirectory: ChakraHost.createDirectory, createDirectory: ChakraHost.createDirectory,
getExecutingFilePath: () => ChakraHost.executingFile, getExecutingFilePath: () => ChakraHost.executingFile,
getCurrentDirectory: () => ChakraHost.currentDirectory, getCurrentDirectory: () => ChakraHost.currentDirectory,
getEnvironmentVariable(name: string) {
return "";
},
readDirectory: ChakraHost.readDirectory, readDirectory: ChakraHost.readDirectory,
exit: ChakraHost.quit, exit: ChakraHost.quit,
}; };

View file

@ -781,7 +781,7 @@ namespace ts {
} }
} }
if (ts.sys.developmentMode && ts.sys.tryEnableSourceMapsForHost) { if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
ts.sys.tryEnableSourceMapsForHost(); ts.sys.tryEnableSourceMapsForHost();
} }