Skip to content

Detect package name mismatch #7604

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 10 commits into from
Jul 11, 2025

Conversation

nojaf
Copy link
Collaborator

@nojaf nojaf commented Jul 5, 2025

Hi @jfrolich, I found the problem for #7493

It turns out that my package.json name key was not exactly the same as what was used in my rescript.json setup. Causing a mismatch in compile.rs.

So, my setup is:
project package.json

  "devDependencies": {
    "@nojaf/rescript-firebase": "github:nojaf/rescript-firebase#56f74c3140f1a32d9ec8626930deb012d66e8c82",
}

So, this gets installed as node_modules/@nojaf/rescript-firebase
But node_modules/@nojaf/rescript-firebase/package.json had "name": "rescript-firebase".
While node_modules/@nojaf/rescript-firebase/rescript.json had "name": "@nojaf/rescript-firebase".

I would be okay with updating my own code. But this does seem like a restriction the previous build system didn't have. So, maybe updating the code (using config.name.clone(),) makes sense.

I'm not sure.

Copy link

pkg-pr-new bot commented Jul 6, 2025

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/win32-x64

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

commit: 69f89ce

@cknitt
Copy link
Member

cknitt commented Jul 10, 2025

@nojaf Can you add a CHANGELOG entry?

@nojaf
Copy link
Collaborator Author

nojaf commented Jul 11, 2025

I'm not sure if this fix is a good idea. Testing it in the test repository is not feasible because having a different name in package.json results in a different folder during the Yarn installation. I believe other package managers might face similar issues, as the package name is usually aligned with the folder name. Therefore, I think it would be best to resolve this problem by aligning the names. It seems reasonable to accept this as a limitation, especially in the case of monorepos where I don't believe there's a workaround.

@nojaf
Copy link
Collaborator Author

nojaf commented Jul 11, 2025

This is actually already part of the docs: https://rescript-lang.org/docs/manual/v11.0.0/build-configuration#name-namespace

Should we convert this PR into a warning-only thing?

@cknitt
Copy link
Member

cknitt commented Jul 11, 2025

Ok, yes, warning only is fine with me!

@nojaf
Copy link
Collaborator Author

nojaf commented Jul 11, 2025

image

@nojaf nojaf requested a review from cknitt July 11, 2025 08:02
@cknitt
Copy link
Member

cknitt commented Jul 11, 2025

@nojaf

- 🛑 Error Cleaning Repo
[1/2] ❌  Error building package tree. The package "@testrepo/package-name-mismatch" is not found (are node_modules up-to-date?)...

@nojaf nojaf merged commit 91a322b into rescript-lang:master Jul 11, 2025
27 checks passed
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