From d062ffc1baeccca8bf168dc1ce4e94b929478142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 11 May 2020 23:48:36 +0200 Subject: fix: source maps in inspector (#5223) This commit fixes problems with source maps in Chrome Devtools by substituting source map URL generated by TS compiler with actual file URL pointing to DENO_DIR. Dummy value of "source_map_url" has been removed from "ScriptOrigin". Also fixes lock file which used compiled source code to generate lock hash; it now uses source code of the file that is being compiled. --- cli/lockfile.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'cli/lockfile.rs') diff --git a/cli/lockfile.rs b/cli/lockfile.rs index 5e43e3420..854d3ea9d 100644 --- a/cli/lockfile.rs +++ b/cli/lockfile.rs @@ -1,8 +1,8 @@ -use crate::tsc::CompiledModule; use serde_json::json; pub use serde_json::Value; use std::collections::HashMap; use std::io::Result; +use url::Url; pub struct Lockfile { need_read: bool, @@ -43,16 +43,17 @@ impl Lockfile { /// Lazily reads the filename, checks the given module is included. /// Returns Ok(true) if check passed - pub fn check(&mut self, m: &CompiledModule) -> Result { - if m.name.starts_with("file:") { + pub fn check(&mut self, url: &Url, code: Vec) -> Result { + let url_str = url.to_string(); + if url_str.starts_with("file:") { return Ok(true); } if self.need_read { self.read()?; } assert!(!self.need_read); - Ok(if let Some(lockfile_checksum) = self.map.get(&m.name) { - let compiled_checksum = crate::checksum::gen2(&m.code); + Ok(if let Some(lockfile_checksum) = self.map.get(&url_str) { + let compiled_checksum = crate::checksum::gen(vec![&code]); lockfile_checksum == &compiled_checksum } else { false @@ -60,11 +61,12 @@ impl Lockfile { } // Returns true if module was not already inserted. - pub fn insert(&mut self, m: &CompiledModule) -> bool { - if m.name.starts_with("file:") { + pub fn insert(&mut self, url: &Url, code: Vec) -> bool { + let url_str = url.to_string(); + if url_str.starts_with("file:") { return false; } - let checksum = crate::checksum::gen2(&m.code); - self.map.insert(m.name.clone(), checksum).is_none() + let checksum = crate::checksum::gen(vec![&code]); + self.map.insert(url_str, checksum).is_none() } } -- cgit v1.2.3