From 44773c9b0fe4ae90089c87aa46d049a0a58cccce Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 14 Mar 2019 19:17:52 -0400 Subject: Integrate //core into existing code base This disables a few tests which are broken still: - tests/error_004_missing_module.test - tests/error_005_missing_dynamic_import.test - tests/error_006_import_ext_failure.test - repl_test test_set_timeout - repl_test test_async_op - repl_test test_set_timeout_interlaced - all of permission_prompt_test --- src/js_errors.rs | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) (limited to 'src/js_errors.rs') diff --git a/src/js_errors.rs b/src/js_errors.rs index f42d9cb51..90c9f2007 100644 --- a/src/js_errors.rs +++ b/src/js_errors.rs @@ -206,36 +206,41 @@ pub fn apply_source_map( } } -fn parse_map_string( - script_name: &str, - getter: &dyn SourceMapGetter, -) -> Option { +// The bundle does not get built for 'cargo check', so we don't embed the +// bundle source map. +#[cfg(feature = "check-only")] +fn builtin_source_map(script_name: &str) -> Option> { + None +} + +#[cfg(not(feature = "check-only"))] +fn builtin_source_map(script_name: &str) -> Option> { match script_name { - // The bundle does not get built for 'cargo check', so we don't embed the - // bundle source map. - #[cfg(not(feature = "check-only"))] - "gen/bundle/main.js" => { - let s = - include_str!(concat!(env!("GN_OUT_DIR"), "/gen/bundle/main.js.map")); - SourceMap::from_json(s) - } - #[cfg(not(feature = "check-only"))] - "gen/bundle/compiler.js" => { - let s = include_str!(concat!( + "gen/bundle/main.js" => Some( + include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/bundle/main.js.map")) + .to_vec(), + ), + "gen/bundle/compiler.js" => Some( + include_bytes!(concat!( env!("GN_OUT_DIR"), "/gen/bundle/compiler.js.map" - )); - SourceMap::from_json(s) - } - _ => match getter.get_source_map(script_name) { - None => None, - Some(raw_source_map) => { - SourceMap::from_json(str::from_utf8(&raw_source_map).unwrap()) - } - }, + )).to_vec(), + ), + _ => None, } } +fn parse_map_string( + script_name: &str, + getter: &dyn SourceMapGetter, +) -> Option { + builtin_source_map(script_name) + .or_else(|| getter.get_source_map(script_name)) + .and_then(|raw_source_map| { + SourceMap::from_json(str::from_utf8(&raw_source_map).unwrap()) + }) +} + fn get_mappings<'a>( script_name: &str, mappings_map: &'a mut CachedMaps, -- cgit v1.2.3