0

For our project we use EcmaScript 6 through Babel, Gulp and npm.

We have three projects: Base, Common and Game.

We're actively developing Common and Game so we have those checked out (and npm link from Game to Common), while we get the Base project through npm and don't change it often.

The import paths we use start with the project name such as import "Base/utils/svg" or import "Game/model/boardtile". The map according to the following on the file system:

  • Base/intellij-project/base-project-src/node_modules/base/
  • Common/intellij-project/base-project-src/js/
  • Game/intellij-project/game-project-src/js/

The problem: IntelliJ does not understand this import scheme. We use the moduleRoot and moduleId options of Babel to identify our AMD modules that way during the gulp build process. When that is done we concatenate everything into one big file. That works, but IntelliJ does not know that we do this magic.

Is there a way to still make IntelliJ understand our imports? So that it will know that Base/utils/svg actually means /intellij-project/base-project-src/node_modules/base/? At the moment the IDE is mostly a glorified text editor, as refactorings obviously relies on the IDE understanding the imports.

Note: Unfortunately I can't change the import structure, as it's a decision I can't change. Nor can I switch to other tools instead of the above mentioned ones, such as WebPack.

1 Answers1

0

I'm facing the same problem with this. I'm looking for a way to get rid of the annoying relative paths as you guys have done, but to get them to work with IntelliJ is another piece of work.

What can help is the symlink approach that can be found here. https://gist.github.com/branneman/8048520

IntelliJ can work nicely with node_modules, so you could symlink a folder in your node_modules to point to the real thing. Then I suppose IntelliJ will be able to resolve your imports.

froginvasion
  • 833
  • 6
  • 19