DEV Community

Discussion on: No More ../../../ Import in React

Collapse
 
krtirtho profile image
Kingkor Roy Tirtho

But What will I do if I've to import from another file that is in the same folder but that folder is nested?
E.g. src/service/backend/post/ is a folder. Inside that I have 2 modules but 1 imports another. So do I've to write it like import {aFunction} from "service/backend/post/module-2" ?

Can I use relative import in that case?

Collapse
 
enthuin profile image
Russell Sanders • Edited

You can still use relative imports. This compiler option only adds to your abilities to do imports, it doesn't take away. you can still use import {aFunction} from "../module-2" and since it's relative, this will still work. The baseUrl option only applies to imports that are not relative, so relative imports still references from the current file

Some comments have been hidden by the post's author - find out more