mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
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.
This commit is contained in:
parent
190776f30d
commit
197d2480bb
@ -72,8 +72,12 @@ pub async fn compile(
|
||||
graph
|
||||
};
|
||||
|
||||
let ts_config_for_emit =
|
||||
cli_options.resolve_ts_config_for_emit(deno_config::TsConfigType::Emit)?;
|
||||
let emit_options =
|
||||
crate::args::ts_config_to_emit_options(ts_config_for_emit.ts_config);
|
||||
let parser = parsed_source_cache.as_capturing_parser();
|
||||
let eszip = eszip::EszipV2::from_graph(graph, &parser, Default::default())?;
|
||||
let eszip = eszip::EszipV2::from_graph(graph, &parser, emit_options)?;
|
||||
|
||||
log::info!(
|
||||
"{} {} to {}",
|
||||
|
@ -1178,3 +1178,32 @@ fn dynamic_import_bad_data_uri() {
|
||||
"[WILDCARD]TypeError: Unable to decode data url.[WILDCARD]",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn standalone_config_file_respects_compiler_options() {
|
||||
let context = TestContextBuilder::new().build();
|
||||
let dir = context.temp_dir();
|
||||
let exe = if cfg!(windows) {
|
||||
dir.path().join("compiler_options.exe")
|
||||
} else {
|
||||
dir.path().join("compiler_options")
|
||||
};
|
||||
context
|
||||
.new_command()
|
||||
.args_vec([
|
||||
"compile",
|
||||
"--allow-read",
|
||||
"--config",
|
||||
"compile/compiler_options/deno.json",
|
||||
"--output",
|
||||
&exe.to_string_lossy(),
|
||||
"./compile/compiler_options/main.ts",
|
||||
])
|
||||
.run()
|
||||
.skip_output_check()
|
||||
.assert_exit_code(0);
|
||||
let output = context.new_command().name(&exe).run();
|
||||
|
||||
output.assert_exit_code(0);
|
||||
output.assert_matches_text("[WILDCARD]C.test() called[WILDCARD]");
|
||||
}
|
||||
|
5
tests/testdata/compile/compiler_options/deno.json
vendored
Normal file
5
tests/testdata/compile/compiler_options/deno.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true
|
||||
}
|
||||
}
|
42
tests/testdata/compile/compiler_options/main.ts
vendored
Normal file
42
tests/testdata/compile/compiler_options/main.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
// deno-lint-ignore-file
|
||||
function a() {
|
||||
console.log("@A evaluated");
|
||||
return function (
|
||||
target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
console.log("@A called");
|
||||
const fn = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
console.log("fn() called from @A");
|
||||
fn();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
function b() {
|
||||
console.log("@B evaluated");
|
||||
return function (
|
||||
target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor,
|
||||
) {
|
||||
console.log("@B called");
|
||||
const fn = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
console.log("fn() called from @B");
|
||||
fn();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
class C {
|
||||
@a()
|
||||
@b()
|
||||
static test() {
|
||||
console.log("C.test() called");
|
||||
}
|
||||
}
|
||||
|
||||
C.test();
|
Loading…
Reference in New Issue
Block a user