Do not use directory import when available doesn't work

Hi!

On my project we prefer index.js imports:

import {store} from '/src/redux/index.js';

over directory imports:

import {store} from '/src/redux/';

I want webstorm autoimport feature to use the first type of import.

I tried unchecking "Use directory import when index.js is available (node-style module resolution)" both in "Editor->Code Style -> JavaScript -> Imports" and "Editor->Code Style -> TypeScript -> Imports", reloaded Webstorm but it still adds import from directory, when I use autoimport :(

8 comments
Comment actions Permalink

This option only works if no path mappings (aliases) are there; please follow https://youtrack.jetbrains.com/issue/WEB-43591 for updates

1
Comment actions Permalink

Thank you for explanation :)

0
Comment actions Permalink

Yes this is extremely annoying. It worked a few weeks ago and now someone changed something in one of our libraries and all the imports add `/index` to the end.
It's not a problem in VS code though. please fix this.

0
Comment actions Permalink

Helo Joe Lloyd 22 24,

Your issue seems to be different. Any chance you could provide some additional information about it? What language is that (JS or TS)? What IDE version do you use? What is the state of the `Use directory import` option mentioned above? Would be great if you have provide a sample project to help us reproduce the problem.

0
Comment actions Permalink

Hi Ekaterina Prigara, I seem to have the same issue where auto-imports add /index to the end. However, I cannot enable the `Use directory import when index.js is available` option as the following screencast illustrates:

https://seafile.cap.secure.josxa.dev/f/f1e722396aaa4eb0bc8b/

It appears to incorrectly assume that the index file has a default export when it only re-exports other members.

1
Comment actions Permalink

Hello Joscha Goetzer!

Why can't you enable this option?

0
Comment actions Permalink

Kristina Pchelintseva As your comment section doesn't allow posting videos, I had to upload it to another host.

"cannot enable ... as the following screencast illustrates: https://seafile.cap.secure.josxa.dev/f/f1e722396aaa4eb0bc8b/"

0
Comment actions Permalink

Joscha Goetzer

Please follow the issue in our tracker

0

Please sign in to leave a comment.