Skip to content

Conversation

zth
Copy link
Member

@zth zth commented Oct 7, 2025

Closes #7052

Improves the circular dependency error slightly, and makes sure it ends up in the compiler logs, so we can add support on the editor side for picking the errors up and showing them in the editor.

@zth zth requested a review from Copilot October 7, 2025 11:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Improve circular dependency error reporting with clearer context and actionable guidance.

  • Enhance cycle formatting to include module display names with relative file paths.
  • Add "How to fix" guidance to the circular dependency error.
  • Append the error message to all involved package logs to surface it via .compiler.log.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
rewatch/tests/snapshots/dependency-cycle.txt Updates snapshot to reflect richer cycle output and guidance text.
rewatch/src/build/compile/dependency_cycle.rs Changes format() to include file paths and requires BuildCommandState; normalizes paths and preserves cycle loop.
rewatch/src/build/compile.rs Integrates new format() signature, adds guidance text, and writes the error to all involved packages' logs.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

zth and others added 2 commits October 7, 2025 13:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

pkg-pr-new bot commented Oct 7, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7940 

@rescript/darwin-arm64

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

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7940 

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7940 

@rescript/win32-x64

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

commit: 948f64d

@zth zth marked this pull request as ready for review October 7, 2025 12:07
@zth zth requested review from cknitt, tsnobip and nojaf October 7, 2025 12:07
Copy link
Member

@tsnobip tsnobip left a comment

Choose a reason for hiding this comment

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

I think the part about namespace can be improved a bit, I can suggest some rewording if I have a better understanding of the use case we're talking about here.


compile_errors.push_str(&format!(
"\n{}\n{}\n",
let guidance = "\nHow to fix:\n- Extract shared code into a new module both depend on.\n- If a namespace entry is part of the cycle, import submodules directly instead of the entry.\n";
Copy link
Member

@tsnobip tsnobip Oct 7, 2025

Choose a reason for hiding this comment

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

I'm not sure if what you mean by

If a namespace entry is part of the cycle, import submodules directly instead of the entry

Do you have any example?
Do you mean you should drop the namespace and directly use the name of the module? Submodule feels a bit weird here given it can be a file module, not necessarily a submodule, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, was going to remove that one, I didn't find a good way to word it. Essentially it's about when you access a module through the main namespace file. But I'll just remove this hint.

Copy link
Member

Choose a reason for hiding this comment

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

I see, for some reason this used to give me error ms using bsb but not with rewatch.

I think indeed that it adds more confusion than it solves, better without it!

@zth zth requested a review from tsnobip October 7, 2025 16:31
@cknitt
Copy link
Member

cknitt commented Oct 7, 2025

@codex review

Copy link

Codex Review: Didn't find any major issues. Another round soon, please!

ℹ️ 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 👍.

@zth zth requested a review from cknitt October 8, 2025 06:33
@zth zth merged commit bac94a4 into master Oct 8, 2025
25 checks passed
@zth zth deleted the circular-deps-errors branch October 8, 2025 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants