diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-11 23:48:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-11 23:48:36 +0200 |
| commit | d062ffc1baeccca8bf168dc1ce4e94b929478142 (patch) | |
| tree | 17992f7781840b619ce528d70b80c9c798d9ce61 /cli/lockfile.rs | |
| parent | 73d8fa74c656841703b51bf8d52d46acf3b97cc9 (diff) | |
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.
Diffstat (limited to 'cli/lockfile.rs')
| -rw-r--r-- | cli/lockfile.rs | 20 |
1 files changed, 11 insertions, 9 deletions
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<bool> { - if m.name.starts_with("file:") { + pub fn check(&mut self, url: &Url, code: Vec<u8>) -> Result<bool> { + 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<u8>) -> 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() } } |
