Custom import paths in a monorepo

I am working on a monorepo project where I have several JavaScript packages. Here is an example project: (just run yarn to set it up).

PhpStorm 2017.3.4 can resolve the imports in packages/a/src/index.js and packages/b/src/index.js. However, PhpStorm Auto Import feature uses relative paths instead of package based imports. I found several issues about this but I found the instructions quite confusing and nothing I tried really worked for me. What I would like auto import to do is:

  • If a module in packages/a imports another module from packages/a then a relative path would be used to import it (../path/to/module).
  • If a module in packages/a imports another module from packages/b then a package import would be used (@my/b/path/to/module).

Is this possible? If not are there similar alternatives?

I found something about a jsconfig.json. Do I need this file? If yes, where should I put it to achieve what I want?

Thank you!


Comment actions Permalink

PhpStorm provides no support for yarn workspaces/monorepo projects; no suitable workarounds can be suggested. Please follow and linked tickets for updates


>I found something about a jsconfig.json. Do I need this file?

No; this file is a VSCode configuration file used for setting up its JavaScript language service; PhpStorm doesn't make any use of it


Comment actions Permalink

I see that is fixed. I have now installed PHPStorm 2018.1.6 but I keep having this issue. Do I need some extra configuration or is my specific issue not fixed yet?

Comment actions Permalink

Seems the fix doesn't affect auto-imports; logged as, please follow it for updates

Comment actions Permalink

Any update on this since 2018? It will be great to be able to resolve multiple webpack configs for a yarn worksapces/monorepo.

Comment actions Permalink was fixed 2 years ago...

Multiple webpack configuration files are not yet supported, please follow for updates


Please sign in to leave a comment.