Skip to content
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

fix: cannot find publish module if cli inside a monorepo package #573

Merged
merged 3 commits into from
Apr 19, 2023

Conversation

johnsoncodehk
Copy link
Contributor

@johnsoncodehk johnsoncodehk commented Apr 15, 2023

Description

Fixes Cannot find package '@lerna-lite/publish' imported from ... error for monorepo projects.

Motivation and Context

How Has This Been Tested?

Types of changes

  • Chore (change that has absolutely no effect on users)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@ghiscoding
Copy link
Member

ghiscoding commented Apr 15, 2023

@johnsoncodehk thanks for the contribution, it looks like the PR is failing because the pnpm lock file is outdated. I also wonder why you got this error and you didn't have this problem before with version 1.x. Are you having this problem because you mark @lerna-lite as an optionalDependencies? All I could find is this Stack Overflow, https://stackoverflow.com/a/66228639/1212166 and I guess it is indeed because of the optional deps, just want to confirm. Thanks

Note that I upgraded to pnpm v8 today, if you are still on v7 and need help to update the lock file then let know and I can update by forking your PR, they changed the lock file structure quite a lot in v8 (see pnpm v8)

EDIT

Actually after relooking at your PR, I'm not that would work in terms of the project. I made publish and version optional and looking at your PR and it looks you're adding back publish as a peer dependency, which basically inverts the work I've done to make these 2 commands optional... unless that is what this peerDependenciesMeta does? Actually seems like it as per npm docs

Specifically, it allows peer dependencies to be marked as optional.

I guess that is what I understood then, it makes the peer deps optional, I need to make sure these 2 commands stay optional without adding peer deps as much as possible. The reason why was because some users are only interested in the run (or exec) command and don't need version neither publish, so I don't want to push it back to them (see issue #450 which was when it was requested). If that is what it does, then I think we should also change "2.0.0" to ">=2.0.0" or "2.x" (I think that works too right)

@johnsoncodehk
Copy link
Contributor Author

johnsoncodehk commented Apr 15, 2023

Your understanding of peerDependenciesMeta is correct, the use of peerDependency is for publish to be promoted to a location that cli can access when using monorepo + pnpm, but there seem still have other similar problems.

I'll try to provide a minimal reproduction tomorrow.

@ghiscoding
Copy link
Member

ghiscoding commented Apr 15, 2023

wow do you ever sleep? go to bed, this can wait 😉

BTW, I'm not getting any errors with the steps you provided (I'm on Windows if it makes any difference). It might be because I upgraded to pnpm v8, I think they've done some changes to peer deps also in pnpm 8

image

@ghiscoding
Copy link
Member

@johnsoncodehk is the PR still required since I couldn't replicate with pnpm 8 (as per my previous comment)?

@johnsoncodehk
Copy link
Contributor Author

Sorry for the delay, I will find time to check today.

@johnsoncodehk
Copy link
Contributor Author

This is a minimal reproduction: https://github.com/johnsoncodehk/lerna-lite-573

@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Merging #573 (6700b7d) into main (60afb34) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #573   +/-   ##
=======================================
  Coverage   98.12%   98.12%           
=======================================
  Files         152      152           
  Lines       11424    11424           
  Branches     2027     2028    +1     
=======================================
  Hits        11209    11209           
  Misses        214      214           
  Partials        1        1           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ghiscoding
Copy link
Member

@johnsoncodehk thanks for the repro, I tried it and do see the error. What I wonder however is this, do we need this change in other package as well? I'm asking because in this case you are only interested in publish since version is a dependency anyway but what about other commands (or even version installed alone without publish), will they suffer from the same problem and should we do this modif for all package? I'm not too familiar with this optionalDependencies so your input would be helpful

@johnsoncodehk
Copy link
Contributor Author

Yes you should make the same changes to all related packages, if you agree I will close the PR and leave it to you.

@ghiscoding ghiscoding merged commit 6cb85d8 into lerna-lite:main Apr 19, 2023
@ghiscoding
Copy link
Member

@johnsoncodehk yeah that's fine, I will merge your PR and contribution and apply this change to all packages later. I assume you can wait few more days right? I mean this is not a blocker is it? Because I have some small CLI issues to resolve with another user and it might take couple days since we aren't on the same TZ (like you and me too ;)

@johnsoncodehk
Copy link
Contributor Author

johnsoncodehk commented Apr 19, 2023

Oh thanks. :)

Yes, I can add error-reporting deps in root package.json to avoid problems.

@ghiscoding
Copy link
Member

ghiscoding commented Apr 19, 2023

@johnsoncodehk
ok thanks, I'll ping you on the next release. Thanks for the contribution :)

Could you review PR #578 that I just opened for all optional commands. I also changed the peer to 2.x since it seems valid as per NodeJS docs and I don't want to update the peer deps every time, unless you think it should be fixed to each Lerna-Lite version release?

@johnsoncodehk
Copy link
Contributor Author

johnsoncodehk commented Apr 19, 2023

2.x is good enough, even * is fine IMO.

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