WebStorm monorepo cross-package auto-import issue

Hi! I know that there are several similar issues and that this should be already fixed but I can't make my project work as intended.

Anytime that I try to import a module from a different package, auto-import uses the relative path.

`import {module} from '../../../../../package/src/module';`

Instead of:

`import {module} from '@package';`

Should I tell WebStorm in some way which is my packages directory? Or should it automatically search inside each package.json to determine how to import modules?

Thank you very much.

Comment actions Permalink

Normally package imports are preferred to relative paths, see https://youtrack.jetbrains.com/issue/WEB-33884

Could you share a sample project the issue can be reproduced with?

Comment actions Permalink

I've just double-checked. The issue is not when using alt+enter to auto-import something when used and not already imported. It is during auto-completion, which is, in my opinion, way more important.

For example, there is an exported myFunction in @someName package.

I start writing: "import {myFunc}" and I get suggestion to import myFunction. However, when I press enter, relative path is used.

The issue that you mentioned is indeed solved.

I think this new issue has to be solved in the same way.

Comment actions Permalink

Auto-import on Alt+Enter normally behaves in the same way as import on completion.

Project sample would be helpful



Please sign in to leave a comment.