1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

refactor: remove dead code in tsc (#7277)

This commit is contained in:
Bartek Iwańczuk 2020-08-31 11:02:13 +02:00 committed by GitHub
parent 39912f2018
commit d761246e16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 94 deletions

View file

@ -55,11 +55,10 @@ pub fn enum_name_media_type(mt: MediaType) -> &'static str {
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, PartialEq, Debug)]
pub enum CompilerRequestType { pub enum CompilerRequestType {
Compile = 0, Compile = 0,
Transpile = 1, Bundle = 1,
Bundle = 2, RuntimeCompile = 2,
RuntimeCompile = 3, RuntimeBundle = 3,
RuntimeBundle = 4, RuntimeTranspile = 4,
RuntimeTranspile = 5,
} }
impl Serialize for CompilerRequestType { impl Serialize for CompilerRequestType {
@ -69,11 +68,10 @@ impl Serialize for CompilerRequestType {
{ {
let value: i32 = match self { let value: i32 = match self {
CompilerRequestType::Compile => 0 as i32, CompilerRequestType::Compile => 0 as i32,
CompilerRequestType::Transpile => 1 as i32, CompilerRequestType::Bundle => 1 as i32,
CompilerRequestType::Bundle => 2 as i32, CompilerRequestType::RuntimeCompile => 2 as i32,
CompilerRequestType::RuntimeCompile => 3 as i32, CompilerRequestType::RuntimeBundle => 3 as i32,
CompilerRequestType::RuntimeBundle => 4 as i32, CompilerRequestType::RuntimeTranspile => 4 as i32,
CompilerRequestType::RuntimeTranspile => 5 as i32,
}; };
Serialize::serialize(&value, serializer) Serialize::serialize(&value, serializer)
} }

View file

@ -406,15 +406,6 @@ delete Object.prototype.__proto__;
target: ts.ScriptTarget.ESNext, target: ts.ScriptTarget.ESNext,
}; };
const DEFAULT_TRANSPILE_OPTIONS = {
esModuleInterop: true,
inlineSourceMap: true,
jsx: ts.JsxEmit.React,
module: ts.ModuleKind.ESNext,
removeComments: true,
target: ts.ScriptTarget.ESNext,
};
const DEFAULT_RUNTIME_COMPILE_OPTIONS = { const DEFAULT_RUNTIME_COMPILE_OPTIONS = {
outDir: undefined, outDir: undefined,
}; };
@ -943,11 +934,10 @@ delete Object.prototype.__proto__;
// Update carefully! // Update carefully!
const CompilerRequestType = { const CompilerRequestType = {
Compile: 0, Compile: 0,
Transpile: 1, Bundle: 1,
Bundle: 2, RuntimeCompile: 2,
RuntimeCompile: 3, RuntimeBundle: 3,
RuntimeBundle: 4, RuntimeTranspile: 4,
RuntimeTranspile: 5,
}; };
function createBundleWriteFile(state) { function createBundleWriteFile(state) {
@ -1452,71 +1442,6 @@ delete Object.prototype.__proto__;
}; };
} }
function transpile({
config: configText,
configPath,
cwd,
performance,
sourceFiles,
}) {
if (performance) {
performanceStart();
}
log(">>> transpile start");
let compilerOptions;
if (configText && configPath && cwd) {
const { options, ...response } = configure(
DEFAULT_TRANSPILE_OPTIONS,
configText,
configPath,
cwd,
);
const diagnostics = processConfigureResponse(response, configPath);
if (diagnostics && diagnostics.length) {
return {
diagnostics: fromTypeScriptDiagnostic(diagnostics),
emitMap: {},
};
}
compilerOptions = options;
} else {
compilerOptions = Object.assign({}, DEFAULT_TRANSPILE_OPTIONS);
}
const emitMap = {};
let diagnostics = [];
for (const { sourceCode, fileName } of sourceFiles) {
const {
outputText,
sourceMapText,
diagnostics: diags,
} = ts.transpileModule(sourceCode, {
fileName,
compilerOptions,
reportDiagnostics: true,
});
if (diags) {
diagnostics = diagnostics.concat(...diags);
}
emitMap[`${fileName}.js`] = { filename: fileName, contents: outputText };
// currently we inline source maps, but this is good logic to have if this
// ever changes
if (sourceMapText) {
emitMap[`${fileName}.map`] = {
filename: fileName,
contents: sourceMapText,
};
}
}
performanceProgram({ fileCount: sourceFiles.length });
const stats = performance ? performanceEnd() : undefined;
log("<<< transpile end");
return {
diagnostics: fromTypeScriptDiagnostic(diagnostics),
emitMap,
stats,
};
}
function bundle({ function bundle({
config, config,
configPath, configPath,
@ -1794,11 +1719,6 @@ delete Object.prototype.__proto__;
opCompilerRespond(result); opCompilerRespond(result);
break; break;
} }
case CompilerRequestType.Transpile: {
const result = transpile(request);
opCompilerRespond(result);
break;
}
case CompilerRequestType.Bundle: { case CompilerRequestType.Bundle: {
const result = bundle(request); const result = bundle(request);
opCompilerRespond(result); opCompilerRespond(result);