summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/99_main_compiler.js16
-rw-r--r--cli/tsc/mod.rs44
2 files changed, 8 insertions, 52 deletions
diff --git a/cli/tsc/99_main_compiler.js b/cli/tsc/99_main_compiler.js
index bd966f03b..68ff2bd39 100644
--- a/cli/tsc/99_main_compiler.js
+++ b/cli/tsc/99_main_compiler.js
@@ -20,9 +20,6 @@ delete Object.prototype.__proto__;
let logDebug = false;
let logSource = "JS";
- /** @type {string=} */
- let cwd;
-
// The map from the normalized specifier to the original.
// TypeScript normalizes the specifier in its internal processing,
// but the original specifier is needed when looking up the source from the runtime.
@@ -349,6 +346,7 @@ delete Object.prototype.__proto__;
// analysis in Rust operates on fully resolved URLs,
// it makes sense to use the same scheme here.
const ASSETS_URL_PREFIX = "asset:///";
+ const CACHE_URL_PREFIX = "cache:///";
/** Diagnostics that are intentionally ignored when compiling TypeScript in
* Deno, as they provide misleading or incorrect information. */
@@ -447,8 +445,9 @@ delete Object.prototype.__proto__;
if (logDebug) {
debug(`host.fileExists("${specifier}")`);
}
- specifier = normalizedToOriginalMap.get(specifier) ?? specifier;
- return ops.op_exists({ specifier });
+ // this is used by typescript to find the libs path
+ // so we can completely ignore it
+ return false;
},
readFile(specifier) {
if (logDebug) {
@@ -527,7 +526,7 @@ delete Object.prototype.__proto__;
if (logDebug) {
debug(`host.getCurrentDirectory()`);
}
- return cwd ?? ops.op_cwd();
+ return CACHE_URL_PREFIX;
},
getCanonicalFileName(fileName) {
return fileName;
@@ -1177,13 +1176,12 @@ delete Object.prototype.__proto__;
}
}
- /** @param {{ debug: boolean; rootUri?: string; }} init */
- function serverInit({ debug: debugFlag, rootUri }) {
+ /** @param {{ debug: boolean; }} init */
+ function serverInit({ debug: debugFlag }) {
if (hasStarted) {
throw new Error("The language server has already been initialized.");
}
hasStarted = true;
- cwd = rootUri;
languageService = ts.createLanguageService(host, documentRegistry);
setLogDebug(debugFlag, "TSLS");
debug("serverInit()");
diff --git a/cli/tsc/mod.rs b/cli/tsc/mod.rs
index 188bc0533..fb9eeba0d 100644
--- a/cli/tsc/mod.rs
+++ b/cli/tsc/mod.rs
@@ -352,7 +352,6 @@ pub struct Request {
pub debug: bool,
pub graph: Arc<ModuleGraph>,
pub hash_data: Vec<Vec<u8>>,
- pub maybe_config_specifier: Option<ModuleSpecifier>,
pub maybe_npm_resolver: Option<NpmPackageResolver>,
pub maybe_tsbuildinfo: Option<String>,
/// A vector of strings that represent the root/entry point modules for the
@@ -374,7 +373,6 @@ pub struct Response {
struct State {
hash_data: Vec<Vec<u8>>,
graph: Arc<ModuleGraph>,
- maybe_config_specifier: Option<ModuleSpecifier>,
maybe_tsbuildinfo: Option<String>,
maybe_response: Option<RespondArgs>,
maybe_npm_resolver: Option<NpmPackageResolver>,
@@ -386,7 +384,6 @@ impl State {
pub fn new(
graph: Arc<ModuleGraph>,
hash_data: Vec<Vec<u8>>,
- maybe_config_specifier: Option<ModuleSpecifier>,
maybe_npm_resolver: Option<NpmPackageResolver>,
maybe_tsbuildinfo: Option<String>,
root_map: HashMap<String, ModuleSpecifier>,
@@ -395,7 +392,6 @@ impl State {
State {
hash_data,
graph,
- maybe_config_specifier,
maybe_npm_resolver,
maybe_tsbuildinfo,
maybe_response: None,
@@ -406,8 +402,7 @@ impl State {
}
fn normalize_specifier(specifier: &str) -> Result<ModuleSpecifier, AnyError> {
- resolve_url_or_path(&specifier.replace(".d.ts.d.ts", ".d.ts"))
- .map_err(|err| err.into())
+ resolve_url_or_path(specifier).map_err(|err| err.into())
}
#[derive(Debug, Deserialize)]
@@ -429,17 +424,6 @@ fn op_create_hash(s: &mut OpState, args: Value) -> Result<Value, AnyError> {
Ok(json!({ "hash": hash }))
}
-#[op]
-fn op_cwd(s: &mut OpState) -> Result<String, AnyError> {
- let state = s.borrow_mut::<State>();
- if let Some(config_specifier) = &state.maybe_config_specifier {
- let cwd = config_specifier.join("./")?;
- Ok(cwd.to_string())
- } else {
- Ok("cache:///".to_string())
- }
-}
-
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
struct EmitArgs {
@@ -466,27 +450,6 @@ fn op_emit(state: &mut OpState, args: EmitArgs) -> bool {
}
#[derive(Debug, Deserialize)]
-struct ExistsArgs {
- /// The fully qualified specifier that should be loaded.
- specifier: String,
-}
-
-#[op]
-fn op_exists(state: &mut OpState, args: ExistsArgs) -> bool {
- let state = state.borrow_mut::<State>();
- let graph = &state.graph;
- if let Ok(specifier) = normalize_specifier(&args.specifier) {
- if specifier.scheme() == "asset" || specifier.scheme() == "data" {
- true
- } else {
- graph.get(&specifier).is_some()
- }
- } else {
- false
- }
-}
-
-#[derive(Debug, Deserialize)]
struct LoadArgs {
/// The fully qualified specifier that should be loaded.
specifier: String,
@@ -866,7 +829,6 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
state.put(State::new(
request.graph.clone(),
request.hash_data.clone(),
- request.maybe_config_specifier.clone(),
request.maybe_npm_resolver.clone(),
request.maybe_tsbuildinfo.clone(),
root_map.clone(),
@@ -912,10 +874,8 @@ pub fn exec(request: Request) -> Result<Response, AnyError> {
fn get_tsc_ops() -> Vec<deno_core::OpDecl> {
vec![
- op_cwd::decl(),
op_create_hash::decl(),
op_emit::decl(),
- op_exists::decl(),
op_is_node_file::decl(),
op_load::decl(),
op_resolve::decl(),
@@ -982,7 +942,6 @@ mod tests {
Arc::new(graph),
hash_data,
None,
- None,
maybe_tsbuildinfo,
HashMap::new(),
HashMap::new(),
@@ -1024,7 +983,6 @@ mod tests {
debug: false,
graph: Arc::new(graph),
hash_data,
- maybe_config_specifier: None,
maybe_npm_resolver: None,
maybe_tsbuildinfo: None,
root_names: vec![(specifier.clone(), MediaType::TypeScript)],