summaryrefslogtreecommitdiff
path: root/src/js_errors.rs
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-03-14 19:17:52 -0400
committerRyan Dahl <ry@tinyclouds.org>2019-03-18 17:17:08 -0400
commit44773c9b0fe4ae90089c87aa46d049a0a58cccce (patch)
tree34bd66dc66dd59b9acd4bb0a48ea576610187e05 /src/js_errors.rs
parent33438b83a2a2597c2b9918475dd5362faa5c1728 (diff)
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
Diffstat (limited to 'src/js_errors.rs')
-rw-r--r--src/js_errors.rs53
1 files changed, 29 insertions, 24 deletions
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<SourceMap> {
+// 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<Vec<u8>> {
+ None
+}
+
+#[cfg(not(feature = "check-only"))]
+fn builtin_source_map(script_name: &str) -> Option<Vec<u8>> {
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<SourceMap> {
+ 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,