summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock8
-rw-r--r--cli/Cargo.toml4
-rw-r--r--cli/emit.rs23
-rw-r--r--cli/lsp/documents.rs26
-rw-r--r--cli/proc_state.rs30
-rw-r--r--cli/tests/testdata/095_cache_with_bare_import.ts.out2
-rw-r--r--cli/tests/testdata/error_011_bad_module_specifier.ts.out2
-rw-r--r--cli/tests/testdata/error_012_bad_dynamic_import_specifier.ts.out2
-rw-r--r--cli/tests/testdata/error_014_catch_dynamic_import_error.js.out4
-rw-r--r--cli/tests/testdata/error_027_bundle_with_bare_import.ts.out2
-rw-r--r--cli/tests/testdata/error_type_definitions.ts.out2
-rw-r--r--cli/tools/test.rs3
-rw-r--r--cli/tsc.rs6
13 files changed, 71 insertions, 43 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8c58bfe22..a368cf392 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -790,9 +790,9 @@ dependencies = [
[[package]]
name = "deno_doc"
-version = "0.22.0"
+version = "0.23.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "366a584bf4486c7d5674e398c7bb8e6c55a871822cea9d217236933d85e25b98"
+checksum = "6cda01f52763197e4cc3cb9f5ab6fea5a5cee2fd76843bc2e7c2193d812f02ad"
dependencies = [
"cfg-if 1.0.0",
"deno_ast",
@@ -836,9 +836,9 @@ dependencies = [
[[package]]
name = "deno_graph"
-version = "0.13.0"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10ec6e60e462d83c3b7c6c482e9c52149e421a6f7f04e2ed32a0749a2655911c"
+checksum = "b72e7615cd00e7c9b93d804fad6c2a25c9c40a647bf3b5cf857f91aa4c107792"
dependencies = [
"anyhow",
"cfg-if 1.0.0",
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 33ead8a5e..cda4606d1 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -41,8 +41,8 @@ winres = "=0.1.11"
[dependencies]
deno_ast = { version = "0.7.0", features = ["bundler", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
deno_core = { version = "0.110.0", path = "../core" }
-deno_doc = "0.22.0"
-deno_graph = "0.13.0"
+deno_doc = "0.23.0"
+deno_graph = "0.14.0"
deno_lint = { version = "0.20.0", features = ["docs"] }
deno_runtime = { version = "0.36.0", path = "../runtime" }
diff --git a/cli/emit.rs b/cli/emit.rs
index 004171f42..c9a90abb7 100644
--- a/cli/emit.rs
+++ b/cli/emit.rs
@@ -264,7 +264,11 @@ fn get_root_names(
graph
.roots
.iter()
- .filter_map(|s| graph.get(s).map(|m| (m.specifier.clone(), m.media_type)))
+ .filter_map(|s| {
+ graph
+ .get(s)
+ .map(|m| (m.specifier().clone(), *m.media_type()))
+ })
.collect()
}
}
@@ -394,7 +398,7 @@ pub(crate) fn check_and_maybe_emit(
// resolve it via the graph.
let specifier = graph.resolve(&specifiers[0]);
let (media_type, source) = if let Some(module) = graph.get(&specifier) {
- (&module.media_type, module.source.clone())
+ (module.media_type(), module.maybe_source().unwrap_or(""))
} else {
log::debug!("module missing, skipping emit for {}", specifier);
continue;
@@ -479,8 +483,8 @@ impl swc::bundler::Load for BundleLoader<'_> {
if let Some(m) = self.graph.get(specifier) {
let (fm, module) = ast::transpile_module(
specifier,
- &m.source,
- m.media_type,
+ m.maybe_source().unwrap_or(""),
+ *m.media_type(),
self.emit_options,
self.cm.clone(),
)?;
@@ -725,7 +729,11 @@ pub(crate) fn valid_emit(
false
} else if let Some(version) = cache.get(CacheType::Version, s) {
if let Some(module) = graph.get(s) {
- version == get_version(module.source.as_bytes(), &config_bytes)
+ version
+ == get_version(
+ module.maybe_source().unwrap_or("").as_bytes(),
+ &config_bytes,
+ )
} else {
// We have a source module in the graph we can't find, so the emit is
// clearly wrong
@@ -798,7 +806,10 @@ pub(crate) fn to_file_map(
| MediaType::Unknown
) {
if let Some(module) = graph.get(&specifier) {
- files.insert(specifier.to_string(), module.source.to_string());
+ files.insert(
+ specifier.to_string(),
+ module.maybe_source().unwrap_or("").to_string(),
+ );
}
}
if let Some(declaration) = cache.get(CacheType::Declaration, &specifier) {
diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs
index cbc839c46..9e4a74ff2 100644
--- a/cli/lsp/documents.rs
+++ b/cli/lsp/documents.rs
@@ -22,6 +22,7 @@ use deno_core::error::AnyError;
use deno_core::parking_lot::Mutex;
use deno_core::url;
use deno_core::ModuleSpecifier;
+use deno_graph::Module;
use lspower::lsp;
use std::collections::BTreeMap;
use std::collections::HashMap;
@@ -253,7 +254,7 @@ struct DocumentInner {
maybe_language_id: Option<LanguageId>,
maybe_lsp_version: Option<i32>,
maybe_module:
- Option<Result<deno_graph::Module, deno_graph::ModuleGraphError>>,
+ Option<Result<deno_graph::EsModule, deno_graph::ModuleGraphError>>,
maybe_navigation_tree: Option<Arc<tsc::NavigationTree>>,
maybe_warning: Option<String>,
specifier: ModuleSpecifier,
@@ -278,13 +279,16 @@ impl Document {
// we only ever do `Document::new` on on disk resources that are supposed to
// be diagnosable, unlike `Document::open`, so it is safe to unconditionally
// parse the module.
- let maybe_module = Some(deno_graph::parse_module(
+ let maybe_module = match deno_graph::parse_module(
&specifier,
maybe_headers,
content.clone(),
maybe_resolver,
Some(&parser),
- ));
+ ) {
+ Ok(m) => m.to_maybe_es_module().map(Ok),
+ Err(err) => Some(Err(err)),
+ };
let dependencies = if let Some(Ok(module)) = &maybe_module {
Arc::new(module.dependencies.clone())
} else {
@@ -316,13 +320,16 @@ impl Document {
let maybe_headers = language_id.as_headers();
let parser = SourceParser::default();
let maybe_module = if language_id.is_diagnosable() {
- Some(deno_graph::parse_module(
+ match deno_graph::parse_module(
&specifier,
maybe_headers,
content.clone(),
maybe_resolver,
Some(&parser),
- ))
+ ) {
+ Ok(m) => m.to_maybe_es_module().map(Ok),
+ Err(err) => Some(Err(err)),
+ }
} else {
None
};
@@ -384,13 +391,16 @@ impl Document {
.map(|li| li.as_headers())
.flatten();
let parser = SourceParser::default();
- Some(deno_graph::parse_module(
+ match deno_graph::parse_module(
&self.0.specifier,
maybe_headers,
content.clone(),
maybe_resolver,
Some(&parser),
- ))
+ ) {
+ Ok(m) => m.to_maybe_es_module().map(Ok),
+ Err(err) => Some(Err(err)),
+ }
} else {
None
};
@@ -495,7 +505,7 @@ impl Document {
fn maybe_module(
&self,
- ) -> Option<&Result<deno_graph::Module, deno_graph::ModuleGraphError>> {
+ ) -> Option<&Result<deno_graph::EsModule, deno_graph::ModuleGraphError>> {
self.0.maybe_module.as_ref()
}
diff --git a/cli/proc_state.rs b/cli/proc_state.rs
index 53321c2cc..1a0f61e71 100644
--- a/cli/proc_state.rs
+++ b/cli/proc_state.rs
@@ -585,7 +585,7 @@ impl ProcState {
| MediaType::Cjs
| MediaType::Mjs
) {
- module.source.as_str().to_string()
+ module.maybe_source().unwrap_or("").to_string()
// The emit may also be missing when a declaration file is in the
// graph. There shouldn't be any runtime statements in the source
// file and if there was, users would be shown a `TS1036`
@@ -598,17 +598,23 @@ impl ProcState {
specifier, media_type
)
};
- let dependencies = module.dependencies.clone();
- let module_entry = ModuleEntry::Module { code, dependencies };
- graph_data.modules.insert(specifier.clone(), module_entry);
- for dep in module.dependencies.values() {
- #[allow(clippy::manual_flatten)]
- for resolved in [&dep.maybe_code, &dep.maybe_type] {
- if let Some(Ok((specifier, referrer_range))) = resolved {
- let specifier =
- graph.redirects.get(specifier).unwrap_or(specifier);
- let entry = graph_data.referrer_map.entry(specifier.clone());
- entry.or_insert_with(|| referrer_range.clone());
+ let dependencies =
+ module.maybe_dependencies().cloned().unwrap_or_default();
+ graph_data.modules.insert(
+ specifier.clone(),
+ ModuleEntry::Module { code, dependencies },
+ );
+ if let Some(dependencies) = module.maybe_dependencies() {
+ for dep in dependencies.values() {
+ #[allow(clippy::manual_flatten)]
+ for resolved in [&dep.maybe_code, &dep.maybe_type] {
+ if let Some(Ok((specifier, referrer_range))) = resolved {
+ let specifier =
+ graph.redirects.get(specifier).unwrap_or(specifier);
+ let entry =
+ graph_data.referrer_map.entry(specifier.clone());
+ entry.or_insert_with(|| referrer_range.clone());
+ }
}
}
}
diff --git a/cli/tests/testdata/095_cache_with_bare_import.ts.out b/cli/tests/testdata/095_cache_with_bare_import.ts.out
index ef4820386..2668a6e08 100644
--- a/cli/tests/testdata/095_cache_with_bare_import.ts.out
+++ b/cli/tests/testdata/095_cache_with_bare_import.ts.out
@@ -1,2 +1,2 @@
-[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ from "file:///[WILDCARD]/095_cache_with_bare_import.ts"
+[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
at file:///[WILDCARD]/095_cache_with_bare_import.ts:[WILDCARD]
diff --git a/cli/tests/testdata/error_011_bad_module_specifier.ts.out b/cli/tests/testdata/error_011_bad_module_specifier.ts.out
index 7d46f6bc8..81be915d1 100644
--- a/cli/tests/testdata/error_011_bad_module_specifier.ts.out
+++ b/cli/tests/testdata/error_011_bad_module_specifier.ts.out
@@ -1,2 +1,2 @@
-[WILDCARD]error: Relative import path "bad-module.ts" not prefixed with / or ./ or ../ from "[WILDCARD]/error_011_bad_module_specifier.ts"
+[WILDCARD]error: Relative import path "bad-module.ts" not prefixed with / or ./ or ../
at [WILDCARD]/error_011_bad_module_specifier.ts:1:28
diff --git a/cli/tests/testdata/error_012_bad_dynamic_import_specifier.ts.out b/cli/tests/testdata/error_012_bad_dynamic_import_specifier.ts.out
index 7ea32f682..7acd66713 100644
--- a/cli/tests/testdata/error_012_bad_dynamic_import_specifier.ts.out
+++ b/cli/tests/testdata/error_012_bad_dynamic_import_specifier.ts.out
@@ -1,5 +1,5 @@
Check [WILDCARD]error_012_bad_dynamic_import_specifier.ts
-error: Uncaught (in promise) TypeError: Relative import path "bad-module.ts" not prefixed with / or ./ or ../ from "[WILDCARD]/error_012_bad_dynamic_import_specifier.ts"
+error: Uncaught (in promise) TypeError: Relative import path "bad-module.ts" not prefixed with / or ./ or ../
at [WILDCARD]/error_012_bad_dynamic_import_specifier.ts:2:35
const _badModule = await import("bad-module.ts");
diff --git a/cli/tests/testdata/error_014_catch_dynamic_import_error.js.out b/cli/tests/testdata/error_014_catch_dynamic_import_error.js.out
index 67cf0e0bb..701ddc3b5 100644
--- a/cli/tests/testdata/error_014_catch_dynamic_import_error.js.out
+++ b/cli/tests/testdata/error_014_catch_dynamic_import_error.js.out
@@ -1,10 +1,10 @@
Caught direct dynamic import error.
-TypeError: Relative import path "does not exist" not prefixed with / or ./ or ../ from "[WILDCARD]/error_014_catch_dynamic_import_error.js"
+TypeError: Relative import path "does not exist" not prefixed with / or ./ or ../
at [WILDCARD]/error_014_catch_dynamic_import_error.js:3:18
at async [WILDCARD]/error_014_catch_dynamic_import_error.js:3:5
Caught indirect direct dynamic import error.
-TypeError: Relative import path "does not exist either" not prefixed with / or ./ or ../ from "[WILDCARD]/subdir/indirect_import_error.js"
+TypeError: Relative import path "does not exist either" not prefixed with / or ./ or ../
at [WILDCARD]/subdir/indirect_import_error.js:1:15
at async [WILDCARD]/error_014_catch_dynamic_import_error.js:10:5
Caught error thrown by dynamically imported module.
diff --git a/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out b/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out
index 3aa4a42a2..12f38c1c5 100644
--- a/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out
+++ b/cli/tests/testdata/error_027_bundle_with_bare_import.ts.out
@@ -1 +1 @@
-[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../ from "file:///[WILDCARD]/error_027_bundle_with_bare_import.ts"
+[WILDCARD]error: Relative import path "foo" not prefixed with / or ./ or ../
diff --git a/cli/tests/testdata/error_type_definitions.ts.out b/cli/tests/testdata/error_type_definitions.ts.out
index 304ec1bdf..a0a536f78 100644
--- a/cli/tests/testdata/error_type_definitions.ts.out
+++ b/cli/tests/testdata/error_type_definitions.ts.out
@@ -1 +1 @@
-[WILDCARD]error: Relative import path "baz" not prefixed with / or ./ or ../ from "[WILDCARD]/type_definitions/bar.d.ts"
+[WILDCARD]error: Relative import path "baz" not prefixed with / or ./ or ../
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index f2b477bf1..c660d6043 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -32,6 +32,7 @@ use deno_core::futures::StreamExt;
use deno_core::serde_json::json;
use deno_core::JsRuntime;
use deno_core::ModuleSpecifier;
+use deno_graph::Module;
use deno_runtime::permissions::Permissions;
use deno_runtime::tokio_util::run_basic;
use log::Level;
@@ -1159,7 +1160,7 @@ pub async fn run_tests_with_watch(
// otherwise this will cause a stack overflow with circular dependencies
output: &mut HashSet<&'a ModuleSpecifier>,
) {
- if let Some(module) = maybe_module {
+ if let Some(Module::Es(module)) = maybe_module {
for dep in module.dependencies.values() {
if let Some(specifier) = &dep.get_code() {
if !output.contains(specifier) {
diff --git a/cli/tsc.rs b/cli/tsc.rs
index c2b4daef2..bc18efee0 100644
--- a/cli/tsc.rs
+++ b/cli/tsc.rs
@@ -384,8 +384,8 @@ fn op_load(state: &mut State, args: Value) -> Result<Value, AnyError> {
specifier
};
let maybe_source = if let Some(module) = state.graph.get(&specifier) {
- media_type = module.media_type;
- Some(module.source.as_str().to_string())
+ media_type = *module.media_type();
+ module.maybe_source().map(String::from)
} else {
media_type = MediaType::Unknown;
None
@@ -416,7 +416,7 @@ fn resolve_specifier(
let media_type = state
.graph
.get(specifier)
- .map_or(&MediaType::Unknown, |m| &m.media_type);
+ .map_or(&MediaType::Unknown, |m| m.media_type());
let specifier_str = match specifier.scheme() {
"data" | "blob" => {
let specifier_str = hash_url(specifier, media_type);