diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5096f630..2e09352643 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,11 +19,12 @@ #### :rocket: New Feature - Add support for Set, Map, WeakSet and WeakMap to `@unboxed`. https://github.com/rescript-lang/rescript/pull/8009 - - Reanalyze: add reactive incremental analysis (`-reactive`, `-runs`, `-churn`) and Mermaid pipeline dumping (`-mermaid`). https://github.com/rescript-lang/rescript/pull/8092 #### :bug: Bug fix +- Fix rewatch swallowing parse warnings (%todo). https://github.com/rescript-lang/rescript/pull/8135 + #### :memo: Documentation #### :nail_care: Polish diff --git a/rewatch/src/build.rs b/rewatch/src/build.rs index 2f4d5ca5d7..5731048e7b 100644 --- a/rewatch/src/build.rs +++ b/rewatch/src/build.rs @@ -261,9 +261,10 @@ pub fn incremental_build( let result_asts = parse::generate_asts(build_state, || pb.inc(1)); let timing_ast_elapsed = timing_ast.elapsed(); - match result_asts { - Ok(_ast) => { + let parse_warnings = match result_asts { + Ok(warnings) => { pb.finish(); + warnings } Err(err) => { logs::finalize(&build_state.packages); @@ -285,7 +286,7 @@ pub fn incremental_build( plain_output, }); } - } + }; let deleted_modules = build_state.deleted_modules.clone(); deps::get_deps(build_state, &deleted_modules); let timing_parse_total = timing_parse_start.elapsed(); @@ -304,6 +305,9 @@ pub fn incremental_build( ); } } + if helpers::contains_ascii_characters(&parse_warnings) { + println!("{}", &parse_warnings); + } mark_modules_with_expired_deps_dirty(build_state); mark_modules_with_deleted_deps_dirty(&mut build_state.build_state); diff --git a/tests/build_tests/build_warn_as_error/input.js b/tests/build_tests/build_warn_as_error/input.js index ca00be7ca8..a23b667429 100644 --- a/tests/build_tests/build_warn_as_error/input.js +++ b/tests/build_tests/build_warn_as_error/input.js @@ -1,11 +1,14 @@ import * as assert from "node:assert"; import { setup } from "#dev/process"; -const { execBuildLegacy, execCleanLegacy } = setup(import.meta.dirname); +const { execBuild, execClean } = setup(import.meta.dirname); -const o1 = await execBuildLegacy(); +const o1 = await execBuild(); -const first_message = o1.stdout +// biome-ignore lint/suspicious/noControlCharactersInRegex: strip ANSI color codes from output +const stripAnsi = s => s.replace(/\x1b\[[0-9;]*m/g, ""); + +const first_message = stripAnsi(o1.stdout) .split("\n") .map(s => s.trim()) .find(s => s === "Warning number 110"); @@ -14,10 +17,10 @@ if (!first_message) { assert.fail(o1.stdout); } -// Second build using -warn-error +110 -const o2 = await execBuildLegacy(["-warn-error", "+110"]); +// Second build using --warn-error +110 +const o2 = await execBuild(["--warn-error", "+110"]); -const second_message = o2.stdout +const second_message = stripAnsi(o2.stdout) .split("\n") .map(s => s.trim()) .find(s => s === "Warning number 110 (configured as error)"); @@ -26,17 +29,17 @@ if (!second_message) { assert.fail(o2.stdout); } -// Third build, without -warn-error +110 +// Third build, without --warn-error +110 // The result should not be a warning as error -const o3 = await execBuildLegacy(); +const o3 = await execBuild(); -const third_message = o3.stdout +const third_message = stripAnsi(o3.stdout) .split("\n") .map(s => s.trim()) - .find(s => s === "Dependency Finished"); + .find(s => s === "Warning number 110 (configured as error)"); -if (!third_message) { +if (o3.status !== 0 || third_message) { assert.fail(o3.stdout); } -await execCleanLegacy(); +await execClean();