Skip to content

Allow clean with invalid module graphs - #8640

Merged
fhammerschmidt merged 3 commits into
masterfrom
fix/clean-invalid-projects
Oct 20, 2026
Merged

fhammerschmidt merged 3 commits into
masterfrom
fix/clean-invalid-projects

Conversation

@fhammerschmidt

@fhammerschmidt fhammerschmidt commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

rescript clean constructed the build graph before removing generated JavaScript. Duplicate module names or another invalid source state could therefore abort cleanup and leave files behind.

Derive both in-source and out-of-source outputs directly from discovered package source files so cleanup does not require compiler discovery or a valid module graph. This also removes generated lib/es6 and lib/js outputs in the project and its dependencies, including dependencies under node_modules. The progress message lists suffixes from all configured package outputs. Cleaning also removes outputs from every package when non-namespaced dependencies share a module name.

Validation

  • make test-rewatch
  • Focused command-parity checks require successful cleanup without a compiler/runtime and with duplicate modules; all six cleanup integration scripts pass with both Rust and OCaml.
  • An isolated regression builds two non-namespaced dependencies separately, confirms both Foo.mjs outputs exist, then checks root cleanup removes both. It passes with this PR and fails with the previous cleanup implementation, which leaves one output behind.
  • The existing invalid-module-graph cleanup regression also passes.
  • cargo test --manifest-path rewatch/Cargo.toml
  • cargo clippy --manifest-path rewatch/Cargo.toml --all-targets --all-features
  • make checkformat

@fhammerschmidt
fhammerschmidt marked this pull request as ready for review September 10, 2026 09:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T13:27:23.416862Z 7795392 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1c1a738fb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rewatch/tests/clean/05-clean-invalid-module-graph.sh Outdated
@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8640

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8640

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8640

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8640

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8640

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8640

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8640

commit: 1d9d3b2

@github-actions

Copy link
Copy Markdown

@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch from f1c1a73 to 96c35a5 Compare September 10, 2026 10:58
@fhammerschmidt
fhammerschmidt changed the base branch from master to fix/gentype-windows-paths September 10, 2026 10:59
@fhammerschmidt
fhammerschmidt added this pull request to stack #8642 September 10, 2026 10:59
@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch 6 times, most recently from 766e69a to 35b5524 Compare September 11, 2026 13:46
@fhammerschmidt
fhammerschmidt force-pushed the fix/gentype-windows-paths branch from 0d7a3c2 to 9ac4780 Compare September 11, 2026 13:49
@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch from 35b5524 to 60b4bb6 Compare September 11, 2026 13:49
@fhammerschmidt
fhammerschmidt force-pushed the fix/gentype-windows-paths branch from 9ac4780 to 0175386 Compare September 11, 2026 14:03
@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch from 60b4bb6 to 5cea2cf Compare September 11, 2026 14:03
@fhammerschmidt
fhammerschmidt force-pushed the fix/gentype-windows-paths branch from 0175386 to b81ba05 Compare September 11, 2026 15:38
@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch from 5cea2cf to 7132187 Compare September 11, 2026 15:38
@fhammerschmidt
fhammerschmidt force-pushed the fix/gentype-windows-paths branch from b81ba05 to 3102f42 Compare September 11, 2026 16:41
@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch from 7132187 to a32a29e Compare September 11, 2026 16:41
@fhammerschmidt

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: a32a29e022

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fhammerschmidt
fhammerschmidt removed this pull request from stack #8642 September 11, 2026 20:25
@fhammerschmidt
fhammerschmidt added this pull request to stack #8650 September 11, 2026 20:25
@fhammerschmidt
fhammerschmidt removed this pull request from stack #8650 October 9, 2026 13:07
@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch from f9b34b1 to 7795392 Compare October 9, 2026 13:09
@fhammerschmidt
fhammerschmidt changed the base branch from fix/gentype-windows-paths to master October 9, 2026 13:09
@fhammerschmidt

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 7795392e21

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cknitt

cknitt commented Oct 13, 2026

Copy link
Copy Markdown
Member

🤖 This review was generated by Claude (Claude Code) on behalf of @cknitt.

Verdict: approve with nits. No correctness bugs found. Dropping BuildState/get_compiler_info/parse_packages lets clean work with duplicate module names, mismatched .res/.resi pairs, or a missing bsc. A bad root rescript.json or unresolvable dependencies still fail, as they should. The new test fails on master.

  • Also fixes an unmentioned bug: the old code keyed modules by name across packages. With two non-namespaced packages that both have src/Foo.res, only the first package's Foo.mjs was deleted. Iterating per package fixes this; might be worth a test.
  • New behaviour not in the changelog (clean.rs:82-96): clean now also deletes out-of-source lib/es6/lib/js outputs, including inside dependencies under node_modules. That's consistent with what the build writes, but the fragment should mention it.
  • Cosmetic:
    • suffix_for_print only lists in-source suffixes, so the message says "Cleaning .mjs files" while .out.mjs files are also deleted (with only out-of-source specs it prints an empty suffix list, which predates this PR).
    • Empty lib/es6/... directories are left behind after out-of-source cleanup.

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.13%. Comparing base (39bd7be) to head (1d9d3b2).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8640   +/-   ##
=======================================
  Coverage   81.13%   81.13%           
=======================================
  Files         456      456           
  Lines       63750    63750           
=======================================
  Hits        51724    51724           
  Misses      12026    12026           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member Author

Added the cross-package regression in 39f186351: it builds two non-namespaced dependencies with Foo.res, verifies both outputs exist, and checks root cleanup removes both. It fails with the previous implementation, which leaves one output behind. The changelog now mentions out-of-source dependency outputs, and progress messages include all configured suffixes. Directory pruning remains a separate cosmetic follow-up. DCO now passes.

@cknitt cknitt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked against current master: on master, clean still aborts on duplicate modules, leaves one output when two non-namespaced packages share a module name, never removes out-of-source outputs, and fails without a findable runtime. With this PR all four cases clean correctly. This matches what the OCaml implementation already does. LGTM.

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@fhammerschmidt
fhammerschmidt force-pushed the fix/clean-invalid-projects branch from 39f1863 to 29a5551 Compare October 20, 2026 13:23
Restore the changelog fragment, duplicate-package regression, and progress
suffix list that were lost during the rebase. Cleanup behavior matches the
approved revision while retaining master's remove_js_file rename and suite
updates.

Validation: Fresh Rust build, all 146 unit tests, all six cleanup integration
tests, Clippy, Rust formatting, shell syntax, and changelog validation pass.

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
The parity suite still expected Rust cleanup to panic without a compiler,
reject a missing runtime, and leave generated files after duplicate-module
errors. Require successful cleanup in both implementations and removal of
both duplicate outputs. Remove the obsolete out-of-source cleanup difference
from the OCaml build-system guide.

Validation: Fresh Rust build, five focused command-parity cases from the CI
script, all six cleanup integration tests for each CLI, canonical suite
coverage, shell syntax, changelog validation, and whitespace checks pass.

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@github-actions

Copy link
Copy Markdown

@fhammerschmidt
fhammerschmidt merged commit 6a3eed1 into master Oct 20, 2026
28 checks passed
@fhammerschmidt
fhammerschmidt deleted the fix/clean-invalid-projects branch October 20, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants