I am currently delving into typescript and eager to start dabbling in creating packages.
Here is the current layout of my project:
myProject/
├── node_modules/
├── src/
│ ├── app
│ ├── index.ts
│ ├── packages
│ ├── database
│ ├── index.ts
├── package.json
├── tsconfig.json
As you can see, my src
directory has an app
folder for my application implementation and a package
folder which is meant to be more abstract, potentially becoming a package in the future.
What I want is to be able to access my package modules by simply writing this in my app folder:
import Database from 'packages/database';
instead of
import Database from '../packages/database/index';
I have tried adjusting the paths
configuration in the tsconfig.json
file but haven't been successful:
{
"compilerOptions": {
...
"baseUrl": ".",
"paths": {
"packages": ["src/packages"]
}
}
}
Of course, I still want to maintain access to the node_modules
folder as well...
Is there a way I can make this work?
Thank you for your advice!