From d761246e16826a3dd3aa73a3e053de72d640b203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 31 Aug 2020 11:02:13 +0200 Subject: [PATCH] refactor: remove dead code in tsc (#7277) --- cli/msg.rs | 18 ++++---- cli/tsc/99_main_compiler.js | 88 ++----------------------------------- 2 files changed, 12 insertions(+), 94 deletions(-) diff --git a/cli/msg.rs b/cli/msg.rs index 5c50c96ab3..3e5000296c 100644 --- a/cli/msg.rs +++ b/cli/msg.rs @@ -55,11 +55,10 @@ pub fn enum_name_media_type(mt: MediaType) -> &'static str { #[derive(Clone, Copy, PartialEq, Debug)] pub enum CompilerRequestType { Compile = 0, - Transpile = 1, - Bundle = 2, - RuntimeCompile = 3, - RuntimeBundle = 4, - RuntimeTranspile = 5, + Bundle = 1, + RuntimeCompile = 2, + RuntimeBundle = 3, + RuntimeTranspile = 4, } impl Serialize for CompilerRequestType { @@ -69,11 +68,10 @@ impl Serialize for CompilerRequestType { { let value: i32 = match self { CompilerRequestType::Compile => 0 as i32, - CompilerRequestType::Transpile => 1 as i32, - CompilerRequestType::Bundle => 2 as i32, - CompilerRequestType::RuntimeCompile => 3 as i32, - CompilerRequestType::RuntimeBundle => 4 as i32, - CompilerRequestType::RuntimeTranspile => 5 as i32, + CompilerRequestType::Bundle => 1 as i32, + CompilerRequestType::RuntimeCompile => 2 as i32, + CompilerRequestType::RuntimeBundle => 3 as i32, + CompilerRequestType::RuntimeTranspile => 4 as i32, }; Serialize::serialize(&value, serializer) } diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js index 4d44375c6d..1bef2cf650 100644 --- a/cli/tsc/99_main_compiler.js +++ b/cli/tsc/99_main_compiler.js @@ -406,15 +406,6 @@ delete Object.prototype.__proto__; 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 = { outDir: undefined, }; @@ -943,11 +934,10 @@ delete Object.prototype.__proto__; // Update carefully! const CompilerRequestType = { Compile: 0, - Transpile: 1, - Bundle: 2, - RuntimeCompile: 3, - RuntimeBundle: 4, - RuntimeTranspile: 5, + Bundle: 1, + RuntimeCompile: 2, + RuntimeBundle: 3, + RuntimeTranspile: 4, }; 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({ config, configPath, @@ -1794,11 +1719,6 @@ delete Object.prototype.__proto__; opCompilerRespond(result); break; } - case CompilerRequestType.Transpile: { - const result = transpile(request); - opCompilerRespond(result); - break; - } case CompilerRequestType.Bundle: { const result = bundle(request); opCompilerRespond(result);