mirror of
https://github.com/denoland/deno.git
synced 2025-01-10 16:11:13 -05:00
parent
a2f126068e
commit
e01664d0ae
5 changed files with 43 additions and 6 deletions
|
@ -763,7 +763,14 @@ impl Graph2 {
|
|||
let root_names: Vec<(ModuleSpecifier, MediaType)> = self
|
||||
.roots
|
||||
.iter()
|
||||
.map(|ms| (ms.clone(), self.get_media_type(ms).unwrap()))
|
||||
.map(|ms| {
|
||||
(
|
||||
// root modules can be redirects, so before we pass it to tsc we need
|
||||
// to resolve the redirect
|
||||
self.resolve_specifier(ms).clone(),
|
||||
self.get_media_type(ms).unwrap(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let maybe_tsbuildinfo = self.maybe_tsbuildinfo.clone();
|
||||
let hash_data =
|
||||
|
@ -793,7 +800,9 @@ impl Graph2 {
|
|||
for emit in &response.emitted_files {
|
||||
if let Some(specifiers) = &emit.maybe_specifiers {
|
||||
assert!(specifiers.len() == 1, "Unexpected specifier length");
|
||||
let specifier = specifiers[0].clone();
|
||||
// The specifier emitted might not be the redirected specifier, and
|
||||
// therefore we need to ensure it is the correct one.
|
||||
let specifier = graph.resolve_specifier(&specifiers[0]);
|
||||
// Sometimes if tsc sees a CommonJS file it will _helpfully_ output it
|
||||
// to ESM, which we don't really want unless someone has enabled the
|
||||
// check_js option.
|
||||
|
@ -805,10 +814,10 @@ impl Graph2 {
|
|||
}
|
||||
match emit.media_type {
|
||||
MediaType::JavaScript => {
|
||||
codes.insert(specifier, emit.data.clone());
|
||||
codes.insert(specifier.clone(), emit.data.clone());
|
||||
}
|
||||
MediaType::SourceMap => {
|
||||
maps.insert(specifier, emit.data.clone());
|
||||
maps.insert(specifier.clone(), emit.data.clone());
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -1139,9 +1148,11 @@ impl Graph2 {
|
|||
// instead.
|
||||
let result = if prefer_types && dep_module.maybe_types.is_some() {
|
||||
let (_, types) = dep_module.maybe_types.clone().unwrap();
|
||||
types
|
||||
// It is possible that `types` points to a redirected specifier, so we
|
||||
// need to ensure it resolves to the final specifier in the graph.
|
||||
self.resolve_specifier(&types).clone()
|
||||
} else {
|
||||
resolved_specifier
|
||||
dep_module.specifier.clone()
|
||||
};
|
||||
|
||||
Ok(result)
|
||||
|
|
|
@ -2859,6 +2859,12 @@ itest!(proto_exploit {
|
|||
output: "proto_exploit.js.out",
|
||||
});
|
||||
|
||||
itest!(redirect_cache {
|
||||
http_server: true,
|
||||
args: "cache --reload http://localhost:4548/cli/tests/subdir/redirects/a.ts",
|
||||
output: "redirect_cache.out",
|
||||
});
|
||||
|
||||
itest!(deno_test_coverage {
|
||||
args: "test --coverage --unstable test_coverage.ts",
|
||||
output: "test_coverage.out",
|
||||
|
|
6
cli/tests/redirect_cache.out
Normal file
6
cli/tests/redirect_cache.out
Normal file
|
@ -0,0 +1,6 @@
|
|||
Download http://localhost:4548/cli/tests/subdir/redirects/a.ts
|
||||
Download http://localhost:4546/cli/tests/subdir/redirects/a.ts
|
||||
Download http://localhost:4545/cli/tests/subdir/redirects/a.ts
|
||||
Download http://localhost:4545/cli/tests/subdir/redirects/b.ts
|
||||
Download http://localhost:4545/cli/tests/subdir/redirects/a.ts
|
||||
Check http://localhost:4548/cli/tests/subdir/redirects/a.ts
|
9
cli/tests/subdir/redirects/a.ts
Normal file
9
cli/tests/subdir/redirects/a.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { createA } from "./b.ts";
|
||||
|
||||
export class A {
|
||||
private _a = "a";
|
||||
}
|
||||
|
||||
export function start(): A {
|
||||
return createA();
|
||||
}
|
5
cli/tests/subdir/redirects/b.ts
Normal file
5
cli/tests/subdir/redirects/b.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { A } from "./a.ts";
|
||||
|
||||
export function createA(): A {
|
||||
return new A();
|
||||
}
|
Loading…
Reference in a new issue