mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
refactor: remove dead code in tsc (#7277)
This commit is contained in:
parent
39912f2018
commit
d761246e16
2 changed files with 12 additions and 94 deletions
18
cli/msg.rs
18
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)
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue