Skip to content

Try to read dependency from the current package. #7770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 15, 2025

Conversation

nojaf
Copy link
Member

@nojaf nojaf commented Aug 14, 2025

I broke this in #7752

@nojaf nojaf requested a review from Copilot August 14, 2025 08:42
Copy link

@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

This PR fixes a regression introduced in #7752 by modifying the read_dependency function to first check for dependencies in the current package's node_modules before falling back to the root node_modules directory.

  • Added logic to check for dependencies in the current package's node_modules directory first
  • Updated error handling to use anyhow! macro instead of string formatting
  • Changed return type from Result<PathBuf, String> to Result<PathBuf>

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

Copy link

pkg-pr-new bot commented Aug 14, 2025

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/win32-x64

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

commit: 7933dea

@nojaf
Copy link
Member Author

nojaf commented Aug 14, 2025

@tsnobip this should resolve your problem I believe.

@tsnobip
Copy link
Member

tsnobip commented Aug 15, 2025

@tsnobip this should resolve your problem I believe.

@nojaf, the resolution of dependencies seems to work but we still have the issue of PPX resolution:

Error in @miriad/web:
sh: /Users/paul/code/miriad/node_modules/rescript-relay/ppx: No such file or directory

  We've found a bug for you!
  /Users/paul/code/miriad/packages/web/src/ProjectDetailsFloatingMenu.res

  Error while running external preprocessor
Command line: /Users/paul/code/miriad/node_modules/rescript-relay/ppx -uncurried '/var/folders/zc/g_l42ngj3gxfg9p9wmjrkxv40000gn/T/ppx6949eaProjectDetailsFloatingMenu.res' '/var/folders/zc/g_l42ngj3gxfg9p9wmjrkxv40000gn/T/ppx9642dcProjectDetailsFloatingMenu.res'

@nojaf
Copy link
Member Author

nojaf commented Aug 15, 2025

Okay, interesting, I have some idea about this.
But I would like to know your project layout a bit more.
DM me if you don't want to share this publicly.

@@ -1,4 +1,4 @@
Cleaned 0/67
Cleaned 0/115
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why this changed so much

Copy link
Member Author

Choose a reason for hiding this comment

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

I added rescript-bun in that last test package.

@nojaf nojaf merged commit 846b904 into rescript-lang:master Aug 15, 2025
27 checks passed
@tsnobip
Copy link
Member

tsnobip commented Aug 15, 2025

I'll share it, no problem :)
Anyway we're back to the same situation as before, that was the goal and the ppx thing is something we'll fix separately!

@tsnobip
Copy link
Member

tsnobip commented Aug 15, 2025

The structure of my monorepo is quite common I think, a yarn v4 monorepo, root package.json and rescript.json, then a folder packages and in this folder the packages that each have their package.json and rescript.json, like packages/web/rescript.json for example.

My issue is with ppxes that are not in the root node_modules but in the package node_modules.

I think current ppx resolution only checks at the root.

@nojaf
Copy link
Member Author

nojaf commented Aug 15, 2025

My issue is with ppxes that are not in the root node_modules but in the package node_modules.

Yup, wanted to hear that part. This PR ensure we look at the package node_modules for dependencies but we don't do this in case of ppx. But should be the same mechanism.

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.

3 participants