Added environment variable to force experimental transformations.
This commit is contained in:
parent
3c344987de
commit
02ebfa5d11
11
Jakefile.js
11
Jakefile.js
|
@ -241,7 +241,6 @@ function concatenateFiles(destinationFile, sourceFiles) {
|
|||
}
|
||||
|
||||
var useDebugMode = true;
|
||||
var useTransforms = process.env.USE_TRANSFORMS || false;
|
||||
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
|
||||
var compilerFilename = "tsc.js";
|
||||
var LKGCompiler = path.join(LKGDirectory, compilerFilename);
|
||||
|
@ -309,8 +308,8 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts
|
|||
options += " --stripInternal"
|
||||
}
|
||||
|
||||
if (useBuiltCompiler && useTransforms) {
|
||||
options += " --experimentalTransforms"
|
||||
if (useBuiltCompiler && Boolean(process.env.USE_TRANSFORMS)) {
|
||||
console.warn("\u001b[93mwarning: Found 'USE_TRANSFORMS' environment variable. Experimental transforms will be enabled by default.\u001b[0m");
|
||||
}
|
||||
|
||||
var cmd = host + " " + compilerPath + " " + options + " ";
|
||||
|
@ -430,10 +429,6 @@ task("setDebugMode", function() {
|
|||
useDebugMode = true;
|
||||
});
|
||||
|
||||
task("setTransforms", function() {
|
||||
useTransforms = true;
|
||||
});
|
||||
|
||||
task("configure-nightly", [configureNightlyJs], function() {
|
||||
var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs;
|
||||
console.log(cmd);
|
||||
|
@ -519,7 +514,7 @@ compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, cop
|
|||
var i = content.lastIndexOf("\n");
|
||||
fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i));
|
||||
});
|
||||
|
||||
|
||||
|
||||
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
|
||||
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
|
||||
|
|
|
@ -994,6 +994,11 @@ namespace ts {
|
|||
|
||||
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 emitResult = fileEmitter(
|
||||
emitResolver,
|
||||
|
|
|
@ -8,7 +8,6 @@ namespace ts {
|
|||
args: string[];
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean;
|
||||
/*@internal*/ developmentMode?: boolean;
|
||||
write(s: string): void;
|
||||
readFile(path: string, encoding?: string): string;
|
||||
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
|
||||
|
@ -23,6 +22,7 @@ namespace ts {
|
|||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getMemoryUsage?(): number;
|
||||
exit(exitCode?: number): void;
|
||||
/*@internal*/ getEnvironmentVariable(name: string): string;
|
||||
/*@internal*/ tryEnableSourceMapsForHost?(): void;
|
||||
}
|
||||
|
||||
|
@ -213,6 +213,9 @@ namespace ts {
|
|||
getCurrentDirectory() {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
getEnvironmentVariable(name: string) {
|
||||
return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings(`%${name}%`);
|
||||
},
|
||||
readDirectory,
|
||||
exit(exitCode?: number): void {
|
||||
try {
|
||||
|
@ -523,7 +526,6 @@ namespace ts {
|
|||
args: process.argv.slice(2),
|
||||
newLine: _os.EOL,
|
||||
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
|
||||
developmentMode: /^development$/i.test(String(process.env.NODE_ENV)),
|
||||
write(s: string): void {
|
||||
process.stdout.write(s);
|
||||
},
|
||||
|
@ -581,6 +583,9 @@ namespace ts {
|
|||
getCurrentDirectory() {
|
||||
return process.cwd();
|
||||
},
|
||||
getEnvironmentVariable(name: string) {
|
||||
return process.env[name] || "";
|
||||
},
|
||||
readDirectory,
|
||||
getMemoryUsage() {
|
||||
if (global.gc) {
|
||||
|
@ -627,6 +632,9 @@ namespace ts {
|
|||
createDirectory: ChakraHost.createDirectory,
|
||||
getExecutingFilePath: () => ChakraHost.executingFile,
|
||||
getCurrentDirectory: () => ChakraHost.currentDirectory,
|
||||
getEnvironmentVariable(name: string) {
|
||||
return "";
|
||||
},
|
||||
readDirectory: ChakraHost.readDirectory,
|
||||
exit: ChakraHost.quit,
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue