JS Module resolution
'../../foo/bar') and if at some point you refactor your code or move it around, then it becomes a pain to change all your imports. We will solve this by using a module resolver (and TypeScript itself).
Setting up module sensible resolution#
You may have noticed in the previous lesson that all of our import statements are relative.
module-resolver allows you to add a "root" directory to all your imports. That is, every time you import a module without using a relative syntax (ex.
./), it will assume you are requiring the file from the "root" directory of the project (in our case "./src"), and it will be transpiled accordingly.
Next, on the root of the project, there is a
babel.config.js file - open it and modify it so it ends up like this: