fix(cli): local sources are not cached in memory (#8328)

Fixes #4743
Closes #5253
Fixes #5631
Fixes #6116

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
This commit is contained in:
Kitson Kelly 2020-11-16 13:19:31 +11:00 committed by GitHub
parent 1079e59cf4
commit 37fbbf8101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 27 deletions

View file

@ -188,7 +188,7 @@ impl ProgramState {
// really should just be getting this from the module graph.
let out = self
.file_fetcher
.get_cached(&module_specifier)
.get_source(&module_specifier)
.expect("Cached source file doesn't exist");
let specifier = out.specifier.clone();
@ -323,7 +323,7 @@ impl SourceMapGetter for ProgramState {
line_number: usize,
) -> Option<String> {
if let Ok(specifier) = ModuleSpecifier::resolve_url(file_name) {
self.file_fetcher.get_cached(&specifier).map(|out| {
self.file_fetcher.get_source(&specifier).map(|out| {
// Do NOT use .lines(): it skips the terminating empty line.
// (due to internally using .split_terminator() instead of .split())
let lines: Vec<&str> = out.source.split('\n').collect();