mirror of
https://github.com/denoland/deno.git
synced 2025-01-12 00:54:02 -05:00
fix(compile): panic when running with a populated dep analysis cache (#15672)
Closes #15612
This commit is contained in:
parent
b62ef4d37b
commit
c3e48cba18
6 changed files with 64 additions and 51 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -982,9 +982,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_doc"
|
name = "deno_doc"
|
||||||
version = "0.43.0"
|
version = "0.44.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "22162c77cbcf8da271482b0facf45e4654cdf72dc09ebc7d8d534650ceb0effe"
|
checksum = "f574fcfacf7b4ecce58c4cb67a3d76c025e4e010863e57f77827eaa9bf41248e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"deno_ast",
|
"deno_ast",
|
||||||
|
@ -1000,9 +1000,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_emit"
|
name = "deno_emit"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d98268720377863f697b8e74955c33d237f527bdecb3e4b134b43390ba0aff40"
|
checksum = "8ae998e26631299d03ba724cef7a2337e06777b6dfeae432dc932810679a5b68"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
|
@ -1061,9 +1061,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_graph"
|
name = "deno_graph"
|
||||||
version = "0.32.0"
|
version = "0.33.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "30317c100055c82f433bffb130c6dc62346f46a5d3de24d14e8913ad7c490c39"
|
checksum = "a8d375dac1b6f7092c29c4603a7795c98b55257d39e108da02dd5b4e42f9d8a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
@ -1601,9 +1601,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "eszip"
|
name = "eszip"
|
||||||
version = "0.25.0"
|
version = "0.26.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "006cd7d8f0b2f0de3a5f21b770974d6f293a2104536f7060033f17b4d63f8e91"
|
checksum = "8043f99a09a1a1d4449ffcd2b068fabf2cb6d70b406e11c2b2d623ce8984baa7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64 0.13.0",
|
"base64 0.13.0",
|
||||||
|
|
|
@ -48,9 +48,9 @@ winres = "=0.1.12"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
deno_ast = { version = "0.17.0", features = ["bundler", "cjs", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "transpiling", "typescript", "view", "visit"] }
|
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_core = { version = "0.148.0", path = "../core" }
|
||||||
deno_doc = "0.43.0"
|
deno_doc = "0.44.0"
|
||||||
deno_emit = "0.7.0"
|
deno_emit = "0.8.0"
|
||||||
deno_graph = "0.32.0"
|
deno_graph = "0.33.0"
|
||||||
deno_lint = { version = "0.32.0", features = ["docs"] }
|
deno_lint = { version = "0.32.0", features = ["docs"] }
|
||||||
deno_runtime = { version = "0.74.0", path = "../runtime" }
|
deno_runtime = { version = "0.74.0", path = "../runtime" }
|
||||||
deno_task_shell = "0.5.0"
|
deno_task_shell = "0.5.0"
|
||||||
|
@ -69,7 +69,7 @@ dprint-plugin-markdown = "=0.14.0"
|
||||||
dprint-plugin-typescript = "=0.71.2"
|
dprint-plugin-typescript = "=0.71.2"
|
||||||
encoding_rs = "=0.8.31"
|
encoding_rs = "=0.8.31"
|
||||||
env_logger = "=0.9.0"
|
env_logger = "=0.9.0"
|
||||||
eszip = "=0.25.0"
|
eszip = "=0.26.0"
|
||||||
fancy-regex = "=0.10.0"
|
fancy-regex = "=0.10.0"
|
||||||
flate2 = "=1.0.24"
|
flate2 = "=1.0.24"
|
||||||
http = "=0.2.6"
|
http = "=0.2.6"
|
||||||
|
|
8
cli/cache/parsed_source.rs
vendored
8
cli/cache/parsed_source.rs
vendored
|
@ -88,7 +88,7 @@ impl ParsedSourceCache {
|
||||||
source: Arc<str>,
|
source: Arc<str>,
|
||||||
media_type: MediaType,
|
media_type: MediaType,
|
||||||
) -> deno_core::anyhow::Result<ParsedSource, deno_ast::Diagnostic> {
|
) -> 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
|
// this will conditionally parse because it's using a CapturingModuleParser
|
||||||
parser.parse_module(specifier, source, media_type)
|
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 {
|
struct ParsedSourceCacheModuleAnalyzer {
|
||||||
|
|
|
@ -247,8 +247,8 @@ async fn compile_command(
|
||||||
|
|
||||||
graph.valid().unwrap();
|
graph.valid().unwrap();
|
||||||
|
|
||||||
let store = ps.parsed_source_cache.as_store();
|
let parser = ps.parsed_source_cache.as_capturing_parser();
|
||||||
let eszip = eszip::EszipV2::from_graph(graph, &*store, Default::default())?;
|
let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
|
|
|
@ -93,25 +93,29 @@ fn bundle_exports_no_check() {
|
||||||
#[test]
|
#[test]
|
||||||
fn bundle_circular() {
|
fn bundle_circular() {
|
||||||
// First we have to generate a bundle of some module that has exports.
|
// First we have to generate a bundle of some module that has exports.
|
||||||
let circular1 = util::testdata_path().join("subdir/circular1.ts");
|
let circular1_path = util::testdata_path().join("subdir/circular1.ts");
|
||||||
assert!(circular1.is_file());
|
assert!(circular1_path.is_file());
|
||||||
let t = TempDir::new();
|
let t = TempDir::new();
|
||||||
let bundle = t.path().join("circular1.bundle.js");
|
let bundle_path = t.path().join("circular1.bundle.js");
|
||||||
let mut deno = util::deno_cmd()
|
|
||||||
|
// 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())
|
.current_dir(util::testdata_path())
|
||||||
.arg("bundle")
|
.arg("bundle")
|
||||||
.arg(circular1)
|
.arg(&circular1_path)
|
||||||
.arg(&bundle)
|
.arg(&bundle_path)
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let status = deno.wait().unwrap();
|
let status = deno.wait().unwrap();
|
||||||
assert!(status.success());
|
assert!(status.success());
|
||||||
assert!(bundle.is_file());
|
assert!(bundle_path.is_file());
|
||||||
|
}
|
||||||
|
|
||||||
let output = util::deno_cmd()
|
let output = util::deno_cmd_with_deno_dir(&t)
|
||||||
.current_dir(util::testdata_path())
|
.current_dir(util::testdata_path())
|
||||||
.arg("run")
|
.arg("run")
|
||||||
.arg(&bundle)
|
.arg(&bundle_path)
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// check the output of the the bundle program.
|
// check the output of the the bundle program.
|
||||||
|
|
|
@ -13,7 +13,9 @@ fn compile() {
|
||||||
} else {
|
} else {
|
||||||
dir.path().join("welcome")
|
dir.path().join("welcome")
|
||||||
};
|
};
|
||||||
let output = util::deno_cmd()
|
// 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())
|
.current_dir(util::root_path())
|
||||||
.arg("compile")
|
.arg("compile")
|
||||||
.arg("--unstable")
|
.arg("--unstable")
|
||||||
|
@ -26,7 +28,7 @@ fn compile() {
|
||||||
.wait_with_output()
|
.wait_with_output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
let output = Command::new(exe)
|
let output = Command::new(&exe)
|
||||||
.stdout(std::process::Stdio::piped())
|
.stdout(std::process::Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -35,6 +37,7 @@ fn compile() {
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
assert_eq!(output.stdout, "Welcome to Deno!\n".as_bytes());
|
assert_eq!(output.stdout, "Welcome to Deno!\n".as_bytes());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn standalone_args() {
|
fn standalone_args() {
|
||||||
|
|
Loading…
Reference in a new issue