My project setup involves the use of Webpack and I have set up aliases for different directories:
alias {
shared/common: path.join(__dirname, 'src/main/js/publish/shared/common')
app/common: path.join(__dirname, 'src/main/js/publish/app/common')
}
In some files, I need to import various modules from a single barrel:
import { Comp1, Comp5, Comp7 } from 'shared/common/components';
To make this work, I created an index.ts file inside shared/common/components:
import { Comp1 } from '.comp1/comp1.comp';
import { Comp2 } from '.comp2/comp2.comp';
import { Comp3 } from '.comp3/comp3.comp';
....
import { CompN } from '.compN/compN.comp';
export {
Comp1,
Comp2,
Comp3,
...
CompN
}
Even though it compiles without errors, WebStorm shows an error in the initial import stating that it cannot resolve all symbols.
I've attempted to mark src/main/js/publish as Resource Root, which contains shared and app directories, but it doesn't solve the issue.
Changing the import to include 'index.ts' works fine:
import { Comp1, Comp5, Comp7 } from 'shared/common/components/index.ts';
Is there a way for WebStorm to recognize index.ts files without explicitly including them in imports?