Can't resolve directory using Resource Root
I'm having trouble resolving directories in my import statements. I have the following file structure.
Content Root/A/B/C/lib.js
Content Root/Navigation.js
I have A/B/C/lib.js under the Content Root of my Module. If I add an import statement as
import Nav from "/A/B/C/lib.js";
to the Navigation.js file located in the Content Root then the path resolves as expected. Because of various reasons I need the import statement to be
import Nav from "B/C/lib.js";
but still have the lib.js file under the "A/B/C" directories in my Module.
Content Root/A/B/C/lib.js
To solve this I was reading that I could mark the "A" directory as a Resource Root then I could reference the "lib.js" file as if Navigation.js was under "A" or "B" is now directly under the Content Root.
import Nav from "B/C/lib.js";
Setting "A" as a Resource Root did not do what I expected as described above. I'm not sure it did anything because I still get "cannot resolved direct 'A'" errors. How can I resolve the path "B/C/lib.js" to a file located under "A/B/C/lib.js"?
IntelliJ IDEA 2016.3.4
Build #IU-163.12024.16, built on January 31, 2017
JRE: 1.8.0_112-release-408-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Please sign in to leave a comment.
In my confusion I posted in two locations, see https://intellij-support.jetbrains.com/hc/en-us/requests/865777 for the followup. -Andy
The solution was to mark A as a resource root, then mark folder one level higher as a source root.