Skip to content

Allow clean with invalid module graphs - #8640

Open
fhammerschmidt wants to merge 4 commits into
masterfrom
fix/clean-invalid-projects
Open

fhammerschmidt wants to merge 4 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
  • 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/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@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: 39f1863

@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
Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@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".

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@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.

Signed-off-by: Florian Hammerschmidt <florianh89@gmail.com>
@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 80.51%. Comparing base (8d51b9c) to head (39f1863).
⚠️ Report is 26 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8640      +/-   ##
==========================================
+ Coverage   80.40%   80.51%   +0.10%     
==========================================
  Files         447      447              
  Lines       60990    61060      +70     
==========================================
+ Hits        49042    49162     +120     
+ Misses      11948    11898      -50     

see 37 files with indirect coverage changes

🚀 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.

Build two non-namespaced dependencies independently and assert both Foo.mjs outputs exist before cleaning their common root. Check both outputs are removed so name-based module deduplication cannot silently leave a package behind.

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

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.

This branch has not been deployed

No deployments
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