DEV Community

Discussion on: [Updated] Simplify the require/import paths in your project and avoid ../../../ circles of hell

Collapse
 
puiutucutu profile image
puiu • Edited

Having done this on past projects in the early days of Webpack, I don't recommend doing it today. It's like sweeping dust under your rug. Yah, it's out of sight but its still in your house.

What exactly is wrong ../../../../../..? It stores state information about your path, but more importantly it lets you know that you're stuff is nested deeply. In my mind, that deep nesting is itself a potential problem - maybe a code smell?

w.r.t to renaming, moving, or otherwise managing files, the work of updating and syncing paths should be handled by your IDE instead. Yes, it will cause new commits to be made for files that depend on those now moved files. But why is that bad?

The only case I can see is working on a team - but if you're files are constantly moving directories I think you have other problems. Plus, you'd still have to update the "alias": { "dir": "./srcDir1" } property in your .babelrc file anyways.

tldr - pointless optimization that adds dependencies, occludes path information, prettifies something that arguably doesn't need prettying up.