summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/Cargo.toml8
-rw-r--r--cli/cache/parsed_source.rs8
-rw-r--r--cli/main.rs4
-rw-r--r--cli/tests/integration/bundle_tests.rs36
-rw-r--r--cli/tests/integration/compile_tests.rs45
5 files changed, 57 insertions, 44 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 5bdf75f33..13cbbfad3 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -48,9 +48,9 @@ winres = "=0.1.12"
[dependencies]
deno_ast = { version = "0.17.0", features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "transpiling", "typescript", "view", "visit"] }
deno_core = { version = "0.148.0", path = "../core" }
-deno_doc = "0.43.0"
-deno_emit = "0.7.0"
-deno_graph = "0.32.0"
+deno_doc = "0.44.0"
+deno_emit = "0.8.0"
+deno_graph = "0.33.0"
deno_lint = { version = "0.32.0", features = ["docs"] }
deno_runtime = { version = "0.74.0", path = "../runtime" }
deno_task_shell = "0.5.0"
@@ -69,7 +69,7 @@ dprint-plugin-markdown = "=0.14.0"
dprint-plugin-typescript = "=0.71.2"
encoding_rs = "=0.8.31"
env_logger = "=0.9.0"
-eszip = "=0.25.0"
+eszip = "=0.26.0"
fancy-regex = "=0.10.0"
flate2 = "=1.0.24"
http = "=0.2.6"
diff --git a/cli/cache/parsed_source.rs b/cli/cache/parsed_source.rs
index b35a89a14..0c9fe5c97 100644
--- a/cli/cache/parsed_source.rs
+++ b/cli/cache/parsed_source.rs
@@ -88,7 +88,7 @@ impl ParsedSourceCache {
source: Arc<str>,
media_type: MediaType,
) -> deno_core::anyhow::Result<ParsedSource, deno_ast::Diagnostic> {
- let parser = CapturingModuleParser::new(None, &self.sources);
+ let parser = self.as_capturing_parser();
// this will conditionally parse because it's using a CapturingModuleParser
parser.parse_module(specifier, source, media_type)
}
@@ -124,6 +124,12 @@ impl ParsedSourceCache {
}
}
}
+
+ /// Creates a parser that will reuse a ParsedSource from the store
+ /// if it exists, or else parse.
+ pub fn as_capturing_parser(&self) -> CapturingModuleParser {
+ CapturingModuleParser::new(None, &self.sources)
+ }
}
struct ParsedSourceCacheModuleAnalyzer {
diff --git a/cli/main.rs b/cli/main.rs
index 79a806f0b..391b4ff0d 100644
--- a/cli/main.rs
+++ b/cli/main.rs
@@ -247,8 +247,8 @@ async fn compile_command(
graph.valid().unwrap();
- let store = ps.parsed_source_cache.as_store();
- let eszip = eszip::EszipV2::from_graph(graph, &*store, Default::default())?;
+ let parser = ps.parsed_source_cache.as_capturing_parser();
+ let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;
info!(
"{} {}",
diff --git a/cli/tests/integration/bundle_tests.rs b/cli/tests/integration/bundle_tests.rs
index dd83f0a95..a2e529000 100644
--- a/cli/tests/integration/bundle_tests.rs
+++ b/cli/tests/integration/bundle_tests.rs
@@ -93,25 +93,29 @@ fn bundle_exports_no_check() {
#[test]
fn bundle_circular() {
// First we have to generate a bundle of some module that has exports.
- let circular1 = util::testdata_path().join("subdir/circular1.ts");
- assert!(circular1.is_file());
+ let circular1_path = util::testdata_path().join("subdir/circular1.ts");
+ assert!(circular1_path.is_file());
let t = TempDir::new();
- let bundle = t.path().join("circular1.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(circular1)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- let output = util::deno_cmd()
+ let bundle_path = t.path().join("circular1.bundle.js");
+
+ // run this twice to ensure it works even when cached
+ for _ in 0..2 {
+ let mut deno = util::deno_cmd_with_deno_dir(&t)
+ .current_dir(util::testdata_path())
+ .arg("bundle")
+ .arg(&circular1_path)
+ .arg(&bundle_path)
+ .spawn()
+ .unwrap();
+ let status = deno.wait().unwrap();
+ assert!(status.success());
+ assert!(bundle_path.is_file());
+ }
+
+ let output = util::deno_cmd_with_deno_dir(&t)
.current_dir(util::testdata_path())
.arg("run")
- .arg(&bundle)
+ .arg(&bundle_path)
.output()
.unwrap();
// check the output of the the bundle program.
diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs
index a3f2e8697..5c9a7f074 100644
--- a/cli/tests/integration/compile_tests.rs
+++ b/cli/tests/integration/compile_tests.rs
@@ -13,27 +13,30 @@ fn compile() {
} else {
dir.path().join("welcome")
};
- let output = util::deno_cmd()
- .current_dir(util::root_path())
- .arg("compile")
- .arg("--unstable")
- .arg("--output")
- .arg(&exe)
- .arg("./test_util/std/examples/welcome.ts")
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
- assert!(output.status.success());
- let output = Command::new(exe)
- .stdout(std::process::Stdio::piped())
- .spawn()
- .unwrap()
- .wait_with_output()
- .unwrap();
- assert!(output.status.success());
- assert_eq!(output.stdout, "Welcome to Deno!\n".as_bytes());
+ // try this twice to ensure it works with the cache
+ for _ in 0..2 {
+ let output = util::deno_cmd_with_deno_dir(&dir)
+ .current_dir(util::root_path())
+ .arg("compile")
+ .arg("--unstable")
+ .arg("--output")
+ .arg(&exe)
+ .arg("./test_util/std/examples/welcome.ts")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ assert!(output.status.success());
+ let output = Command::new(&exe)
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ assert!(output.status.success());
+ assert_eq!(output.stdout, "Welcome to Deno!\n".as_bytes());
+ }
}
#[test]