summaryrefslogtreecommitdiff
path: root/cli/ops/compiler.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-11-25 15:33:23 +0100
committerRy Dahl <ry@tinyclouds.org>2019-11-25 09:33:23 -0500
commit658ec2aaf9c7e0d0b4ded4e97a3d89dc2fa25806 (patch)
tree1996038f0f62ed207fe5a1adb518a299eafbe0c8 /cli/ops/compiler.rs
parentbca23e64339f9b41272e4a01e4c1a86602e5c1e4 (diff)
better error message for missing module (#3402)
Diffstat (limited to 'cli/ops/compiler.rs')
-rw-r--r--cli/ops/compiler.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs
index fdb62ca32..b45f6d937 100644
--- a/cli/ops/compiler.rs
+++ b/cli/ops/compiler.rs
@@ -51,7 +51,7 @@ fn op_cache(
#[derive(Deserialize)]
struct FetchSourceFilesArgs {
specifiers: Vec<String>,
- referrer: String,
+ referrer: Option<String>,
}
fn op_fetch_source_files(
@@ -65,14 +65,23 @@ fn op_fetch_source_files(
// to this. Need a test to demonstrate the hole.
let is_dyn_import = false;
+ let (referrer, ref_specifier) = if let Some(referrer) = args.referrer {
+ let specifier = ModuleSpecifier::resolve_url(&referrer)
+ .expect("Referrer is not a valid specifier");
+ (referrer, Some(specifier))
+ } else {
+ // main script import
+ (".".to_string(), None)
+ };
+
let mut futures = vec![];
for specifier in &args.specifiers {
let resolved_specifier =
- state.resolve(specifier, &args.referrer, false, is_dyn_import)?;
+ state.resolve(specifier, &referrer, false, is_dyn_import)?;
let fut = state
.global_state
.file_fetcher
- .fetch_source_file_async(&resolved_specifier);
+ .fetch_source_file_async(&resolved_specifier, ref_specifier.clone());
futures.push(fut);
}