Skip to content

Commit 197d248

Browse files
authored
fix(compile): respect compiler options for emit (#22521)
`deno compile` was ignoring configuration file and thus not applying `compilerOptions` to influence the way files were emitted.
1 parent 190776f commit 197d248

File tree

4 files changed

+81
-1
lines changed

4 files changed

+81
-1
lines changed

cli/tools/compile.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ pub async fn compile(
7272
graph
7373
};
7474

75+
let ts_config_for_emit =
76+
cli_options.resolve_ts_config_for_emit(deno_config::TsConfigType::Emit)?;
77+
let emit_options =
78+
crate::args::ts_config_to_emit_options(ts_config_for_emit.ts_config);
7579
let parser = parsed_source_cache.as_capturing_parser();
76-
let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;
80+
let eszip = eszip::EszipV2::from_graph(graph, &parser, emit_options)?;
7781

7882
log::info!(
7983
"{} {} to {}",

tests/integration/compile_tests.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,3 +1178,32 @@ fn dynamic_import_bad_data_uri() {
11781178
"[WILDCARD]TypeError: Unable to decode data url.[WILDCARD]",
11791179
);
11801180
}
1181+
1182+
#[test]
1183+
fn standalone_config_file_respects_compiler_options() {
1184+
let context = TestContextBuilder::new().build();
1185+
let dir = context.temp_dir();
1186+
let exe = if cfg!(windows) {
1187+
dir.path().join("compiler_options.exe")
1188+
} else {
1189+
dir.path().join("compiler_options")
1190+
};
1191+
context
1192+
.new_command()
1193+
.args_vec([
1194+
"compile",
1195+
"--allow-read",
1196+
"--config",
1197+
"compile/compiler_options/deno.json",
1198+
"--output",
1199+
&exe.to_string_lossy(),
1200+
"./compile/compiler_options/main.ts",
1201+
])
1202+
.run()
1203+
.skip_output_check()
1204+
.assert_exit_code(0);
1205+
let output = context.new_command().name(&exe).run();
1206+
1207+
output.assert_exit_code(0);
1208+
output.assert_matches_text("[WILDCARD]C.test() called[WILDCARD]");
1209+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"compilerOptions": {
3+
"experimentalDecorators": true
4+
}
5+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// deno-lint-ignore-file
2+
function a() {
3+
console.log("@A evaluated");
4+
return function (
5+
target: any,
6+
propertyKey: string,
7+
descriptor: PropertyDescriptor,
8+
) {
9+
console.log("@A called");
10+
const fn = descriptor.value;
11+
descriptor.value = function () {
12+
console.log("fn() called from @A");
13+
fn();
14+
};
15+
};
16+
}
17+
18+
function b() {
19+
console.log("@B evaluated");
20+
return function (
21+
target: any,
22+
propertyKey: string,
23+
descriptor: PropertyDescriptor,
24+
) {
25+
console.log("@B called");
26+
const fn = descriptor.value;
27+
descriptor.value = function () {
28+
console.log("fn() called from @B");
29+
fn();
30+
};
31+
};
32+
}
33+
34+
class C {
35+
@a()
36+
@b()
37+
static test() {
38+
console.log("C.test() called");
39+
}
40+
}
41+
42+
C.test();

0 commit comments

Comments
 (0)