Skip to content

[rush] Follow-ups to #5123.#5179

Closed
iclanton wants to merge 32 commits intomicrosoft:mainfrom
iclanton:5123-followups
Closed

[rush] Follow-ups to #5123.#5179
iclanton wants to merge 32 commits intomicrosoft:mainfrom
iclanton:5123-followups

Conversation

@iclanton
Copy link
Copy Markdown
Member

@iclanton iclanton commented Apr 3, 2025

Summary

Follow-ups to #5123. I put some comments on that PR after it went in, and addressed most of them here.

@L-Qun, FYI.

An issue I noticed: the help text for rush bridge-package says:

This command enables you to test a locally built project by simulating its 
installation under the Rush workspace node_modules folders. Unlike "pnpm 
link" and "npm link", this command updates all installation doppelgangers for 
the specified version range, potentially affecting multiple projects across 
the workspace, as well as their indirect dependencies. The symlink is not 
reflected in pnpm-lock.yaml, and ignores the local project's own package.json 
dependencies, preserving whatever the lockfile installed. The symlink will be 
cleared when you next run "rush install" or "rush update". Compare with the 
"rush link-package" command, which affects only the consuming project.

This sounds like rush bridge-pacakge --path /path/to/local/react --version 1.2.3 will replace all instances of react@1.2.3 in the workspace with a symlink to /path/to/local/react, but that isn't what it does. It seems to do the same thing that rush link-package does in a single project or in specified projects, but by replacing dependencies. Perhaps that would be better conveyed with a --use-repo-dependencies flag on rush link-package?

How it was tested

Tested by linking and bridging a local copy of a package called "react" into this repo.

@github-project-automation github-project-automation Bot moved this to Needs triage in Bug Triage Apr 3, 2025
Comment thread libraries/rush-lib/src/utilities/RushConnect.ts
});
})
},
{ concurrency: 10 }
Copy link
Copy Markdown
Contributor

@L-Qun L-Qun Apr 3, 2025

Choose a reason for hiding this comment

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

Why do you use concurrency: 10 instead of Promise.all to implement concurrency

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Promise.all doesn't limit concurrency at all, so can cause excessive resource consumption for disk and network operations.

return 'Caching has been disabled for this project because it is a linked package.';
const rushConnect: RushConnect = RushConnect.loadFromRushConfiguration(rushConfiguration);
if (rushConnect.hasAnyLinksInSubspace(this.project.subspace.subspaceName)) {
return 'Caching has been disabled for this project because it is in a subspace that has a link.';
Copy link
Copy Markdown
Collaborator

@octogonz octogonz Apr 3, 2025

Choose a reason for hiding this comment

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

"Caching has been disabled for this project because it is in a subspace that has a link."

Has a link? What kind of link?

Maybe this feature would benefit from a special terminology like "hotlink" or "live link" or "devlink" etc. The key concepts being:

  1. The symlink is temporary, for testing purposes, and reset when you run "rush install" again.
  2. The symlink is not reflected in the lockfile or committed to Git.
  3. The symlink may violate SemVer expectations.

Copy link
Copy Markdown
Collaborator

@octogonz octogonz Apr 3, 2025

Choose a reason for hiding this comment

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

Sample usage of such a term:

"The rush link-package and rush bridge-package commands both facilitate testing locally built changes by creating hotlinks to library project folders."

"Caching has been disabled for this project because it is in a subspace that has a hotlink."

Comment thread libraries/rush-lib/src/api/test/__snapshots__/RushCommandLine.test.ts.snap Outdated
Comment thread libraries/rush-lib/src/cli/actions/BridgePackageAction.ts Outdated
@iclanton
Copy link
Copy Markdown
Member Author

iclanton commented Apr 3, 2025

Note that this repro was produced by running the version of rush-lib that is currently in main, and not in this feature branch

For the bridge-package behavior not replacing the package for all consumers of the repo, here are repro steps:

  1. Create a react stub package (mine is at ~/code/temp/react-stub/ for the sake of this repro) with package.json contents:
{
  "name": "react",
  "version": "19.1.1",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "left-pad": "^1.3.0"
  }
}
  1. rush build --to rush-lib
  2. Go to build-tests-samples/heft-webpack-basic-tutorial
  3. Run node ../../libraries/rush-lib/lib/start bridge-package --path ~/code/temp/react-stub
  4. Observe that build-tests-samples/heft-webpack-basic-tutorial/node_modules/react is the stub package, but build-tests-samples/heft-web-rig-library-tutorial/node_modules/react is not.
build-tests-samples/heft-webpack-basic-tutorial build-tests-samples/heft-web-rig-library-tutorial
image image

Note that subsequently running node ../../libraries/rush-lib/lib/start bridge-package --path ~/code/temp/react-stub --version 17.0.2 produces behavior that seems similiar to what is expected, except that there is an odd node_modules/.bin/loose-envify script stuck inside the node_modules/react folders (except for the one in the project where the command was run):
image

Another invocation of node ../../libraries/rush-lib/lib/start bridge-package --path ~/code/temp/react-stub --version 17.0.2 yields this error message:

$ node ../../libraries/rush-lib/lib/start bridge-package --path ~/code/temp/react-stub --version 17.0.2 

Rush Multi-Project Build Tool 5.151.0 (unmanaged) - https://rushjs.io
Node.js version is 20.16.0 (LTS)

Found configuration in /Users/ianc/code/rushstack5/rush.json

Starting "rush bridge-package"


ERROR: Failed to bridge package "/Users/ianc/code/temp/react-stub" to "heft-webpack-basic-tutorial": Cannot find package react in <repo root>/common/temp/default/node_modules/.pnpm

@L-Qun
Copy link
Copy Markdown
Contributor

L-Qun commented Apr 3, 2025

@iclanton
Regarding the first issue, do you mean that the react dependency in build-tests-samples/heft-web-rig-library-tutorial wasn't replaced? If so, that's expected because you're running the command in build-tests-samples/heft-webpack-basic-tutorial, and the command rush bridge-package --path ~/code/temp/react-stub is intended for packages that don't have react installed.

@L-Qun
Copy link
Copy Markdown
Contributor

L-Qun commented Apr 3, 2025

@iclanton
image
For the second issue, you can check whether React is already under your .pnpm folder.

@L-Qun
Copy link
Copy Markdown
Contributor

L-Qun commented Apr 3, 2025

@iclanton
image
At the same time, make sure that the React version meets the requirements.

@L-Qun
Copy link
Copy Markdown
Contributor

L-Qun commented Apr 3, 2025

I think both of them are expected

@octogonz
Copy link
Copy Markdown
Collaborator

octogonz commented Apr 4, 2025

Note that this repro was produced by running the version of rush-lib that is currently in main, and not in this feature branch

@L-Qun has said he will address this in a second PR before we publish

@octogonz octogonz enabled auto-merge (squash) April 4, 2025 07:48
@octogonz octogonz disabled auto-merge April 4, 2025 07:49
@octogonz
Copy link
Copy Markdown
Collaborator

octogonz commented Apr 4, 2025

Merged via #5182

@octogonz octogonz closed this Apr 4, 2025
@github-project-automation github-project-automation Bot moved this from Needs triage to Closed in Bug Triage Apr 4, 2025
@iclanton iclanton deleted the 5123-followups branch October 3, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

3 participants