Is there a way to allow users to import from subfolders of my TypeScript NPM package? For instance, if the TypeScript code is structured like this:
- lib
- src
- server
- react
Users should be able to import from the subfolders as package-name/react
, package-name/server
, etc.
My tsconfig.json configuration looks like this:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"declaration": true,
"outDir": "./lib",
"strict": true,
"jsx": "react",
"esModuleInterop": true
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
}
I was able to achieve this when setting "outDir" to the project root, but it made the file structure messy. Can anyone suggest a solution for importing from submodules while keeping "outDir": "./lib"? Any helpful responses would be greatly appreciated. Thank you in advance.