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

[rush] making the monorepo a "project" causes rush to ignore sub-projects in the monorepo. #1702

Open
1 of 2 tasks
trusktr opened this issue Jan 21, 2020 · 1 comment
Open
1 of 2 tasks

Comments

@trusktr
Copy link

trusktr commented Jan 21, 2020

Is this a feature or a bug?

  • Feature
  • Bug?

I'm trying to incrementally migrate a project to using rush. I don't want to modify the root level of the repo, which itself is an NPM package.

However, I want to add a packages folder and manage packages in there with rush.

When I started using rush in the repo, I didn't do anything with the root, I added the packages folder and started managing things in there with rush, one at time. It worked great! For example, rush add ... && rush update && rush build works great inside of packages in the packages folder.

rush.json contains this:

    "projects": [
        {
            "packageName": "readem",
            "projectFolder": "packages/readem"
        },
        {
            "packageName": "test",
            "projectFolder": "packages/test"
        }
    ]

So far, so good, with only rush-managed packages inside packages/. Loving how it works!

Then I decided to add the root-level as a package, to also manage that with rush (and without having to completely change the repo structure just yet).

So then I changed projects in rush.json to this:

    "projects": [
        {
            "packageName": "readem",
            "projectFolder": "packages/readem"
        },
        {
            "packageName": "test",
            "projectFolder": "packages/test"
        },
        {
            "packageName": "top-secret",
            "projectFolder": "."
        }
    ]

Please describe the actual behavior.

I ran rush update and at this point it ignored the other two projects, only setting up node_modules for the root-level project (with symlinks to common/temp/node_modules as expected). It did not set up node_modules for the other two projects (but I didn't realize this yet).

Then I ran rush build and it did try to build the sub-folder projects in packages/. The console output does successfully show X of 3 messages, indicating that it will try to build all three projects (note the build process of the root-level project does not touch any files in the sub-folder projects). However the build failed due obviously to the missing node_modules in the sub-folder projects.

I also tried running rush add ... inside a sub-folder dependency, but this added the dependency to the root-level project instead of in the sub-folder project.

What is the expected behavior?

That it would be able to handle the case of having the root of the repo (where rush.json is located) as a rush project itself, along with rush projects in sub-folders of the top-level rush project.

Solution?

I'm not sure if there's any other changes needed, but so far it looks like rush build can be updated so that it will still handle installing node_modules for the sub-folder projects, and then after this rush build will work as expected.

The rush add command would need to realize that we're in a sub-folder project (or, any project for that matter, it can check against rush.json), and thus operate on the current project rather than moving up to the higher-up project.

Use cases

This would be useful for existing projects to be able to manage packages in sub-folders (for example split some common code from the root-level project into separate new packages to publish on NPM) without having to modify the file-system structure of the root project (this can cause conflicts with other people's work, etc, and is generally not ideal if it can be avoided). EDIT: to workaround this I can move rush files (rush.json, common/, etc) into a parent folder, and make the root project (which is a git repo) a sub-folder of the folder that has only rush stuff, and now move out the other projects into the new common parent so that the previously-root project no longer contains sub-folders with rush projects.

This would help people incrementally adopt rush, so they can simply add a folder and get going. They would be able to rush init in the root-level and rush would add common/ and rush.json there, then they can simply place packages in sub-folders.

As a coincidence, this will allow a tree of rush projects (rush projects that manage rush projects that manage rush projects) to be possible, as in #1699. rush would traverse up to find the nearest rush.json.

If this is a bug, please provide the tool version, Node.js version, and OS.

  • Tool: rush
  • Tool Version: 5.17
  • Node Version: 12.13
  • OS: macOS
@trusktr
Copy link
Author

trusktr commented Jan 21, 2020

Duplicate of #1671

@trusktr trusktr changed the title root-level package causes rush to semi-ignore sub-folder projects in the root-level package. [rush] root-level package causes rush to semi-ignore sub-folder projects in the root-level package. Jan 21, 2020
@trusktr trusktr changed the title [rush] root-level package causes rush to semi-ignore sub-folder projects in the root-level package. [rush] making the monorepo a "project" causes rush to ignore sub-projects in the monorepo. Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Investigation
Development

No branches or pull requests

1 participant