How to handle monorepo - separate indexing/autocompletes by root directories

Hi. I have monorepo with multiple JS and PHP directories.

The problem is that IDE (PhpStorm) is indexing all together.

For ex. in frontend directory while typing something in class="" autocompletion suggests me some classes found in backend vendor.

Is there any feature in IntelliJ IDEA to separate root directories? I want to stay in single IDE window. Is there something like "subproject"? I found in google about Modules and it seems to be exactly what I need, but this feature is only in Java IDE. What about phpstorm?

 

5

I'd suggest to open a particular directory as a project, instead of opening the whole "monorepo".

If you need code completion from another source root for that project - simply add it at File | Settings (Preferences on Mac) | PHP > "Include Path".

If that wouldn't work for you - please describe in details why.

There are unfortunately no options to configure what "modules" or source roots to have code completion from on the fly. 

You can of course mark unnecessary folders (e.g. backend vendor) as "excluded", but that wouldn't work right as soon as you start to work on another project in this monorepo.

-4

Thanks for answer. Sure I can open every directory as separate project, but I do not like to switching between multiple IDE windows. Let's say I have API, frontend, dashboard separated. While adding some feature I could be coding in all of them, this means I need to shuffle between 3 IDE windows.
Instead I have big panoramic monitor, so it is better for me to have multiple tabs groups, for example on the left js/vue (frontend) files, in the middle php (backend) etc.

It all works great, except this indexing. I cannot exclude backend vendor because I need this, but only in backend files.

0

You can open multiple projects in one window: use File > Open to open a directory with e.g. API, then File > Open again to open "frontend" & select "Attach". Do the same with "dashboard".

That way you'll have only the necessary directories opened/indexed. That's very similar to working with modules in IntelliJ IDEA.

Just bear in mind that the first project/directory you'd open would be considered as "primary". All the project-related settings would get loaded using its preferences, not the settings from "attached" projects.

1

So i tried this. By doing this I do not have access to files in main root directory (like Readme). But this is better than before, so thanks ;) But it would be still nice to have other option to just open whole repository and set it to multiroot mode or something. 

0

I see. Unfortunately there are no similar requests on our tracker and, honestly saying, I don't think this would get implemented anytime soon: this feature looks like a lot of work. Still, you can submit this to our tracker at https://youtrack.jetbrains.com/newIssue.

-7

Sorry to revive this, but actually, this is just the n-th request asking to have an Eclipse-style workspace...

3

I apologize for reviving an old thread, but I have a similar issue/question. One of the repos I'm working with is a single GitHub repository with several, loosely related "packages" under it in separate subtrees for a web app frontend, the backend services for that frontend, and end-to-end tests. The E2E test tree is a mature, Cypress-based test framework, which I am looking at making function within Aqua, as I think it would be helpful if the frontend developers and test automators used the same IntelliJ-based toolset. Currently, the E2E tests can be launched from a CI build or from the terminal. So far, it's a little bit like putting an octagon-shaped peg into a round hole - it almost fits, but doesn't. I think it might help if the E2E subtree could be recognized by Aqua as containing Cypress tests instead Jest tests, but it's not clear whether that is possible within a subtree of a project.

I'll likely open an issue if I can't figure it out, but I wanted to comment here to provide an example where separate teams may be working on a whole repo or just a subtree within a monorepo and may want the ability for their JetBrains editor to consider their subtree to be a subproject within a larger project.

1

It's 2024, and they still haven't fixed this. By the way, this affects not just PhpStorm, but all Intellij products. I'm using the Ultimate version.

2

I came across this trying to figure out why I was having so much trouble setting up separate settings for my infrastructure as code and application code with the built in type hinting insisting that everything is wrong the further I progress in separating the two.  The lack of support for a monorepo explains a lot.  While I can probably work around, it having this feature would be really really useful. 

0

It has been getting a lot worse recently. First my old Macbook couldn't handle it, upgraded to M1 32 Gigs, now again waiting all day on IntelliJ's code completion Prettier and Eslint. We're even running in Vite and all so should be less heavy. 

The first suggestion here I think is ridiculous and I find it even a bit insulting. IntelliJ should be able to run monorepo's, it's a leading IDE and VSCode can also handle it. Please think of something better than having 1000 different windows for all projects.

0

Same issue over here, every update it gets worse. I use a Macbook pro M3 pro with 18gb of ram and when I open one file in my monorepo it takes ages to index, load code completion etc. If this won't be fixed by this year, I will look elsewhere.

1

I can't believe this haven't been fixed yet.

2

2025 it is not resolved

1

Come on JetBrains. I’m beginning to find it hard to justify paying for your IDE. 

1

It stays awkwardly silent on the side of Jetbrains.. I only work in a monorepo all day, feels like I'm on some granny computer while I'm working on a M1 with 32GB RAM. 

2

Same here. Problem got bigger with latest update. Now indexing stays stuck even when I open monorepo dir separately sometimes.

Working with monorepo is now close to impossible - even with power saver mode. Indexing stays stuck every time. Repair or clear caches does nothing.

I think this might be because of yarn workspaces and their pnpm linker which creats circular dependencies. Indexer can't handle that (symlinks) somehow.

It helped a bit to mark all node_modules as excluded but not much. Now ui doesn't get stuck totally, storm just using 100% cpu all the time (and it doesn't stop).

I don't like vscode nor eclipse but I'll give them a try now because I can't work anulymore in storm… 

1

请先登录再写评论。