I'm trying to create a package with directory structure as follow:
src/
folder1/
index.ts
...
folder2/
index.ts
...
folder3/
index.ts
...
.
.
.
And I would like to import it as import { Class1 } from '@package/folder1'
, import { Class2 } from '@package/folder2'
, etc.
At this moment, I'm able to import my classes like import { Class1 } from '@package/lib/folder1'
. Is it possible to achieve my expected behavior?
tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./lib",
"rootDir": "./src",
"rootDirs": ["./src/folder1"],
"lib": [
"es2017",
"esnext.asynciterable"
],
"typeRoots": [
"./node_modules/@types"
],
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"pretty": true,
"noEmit": false,
"esModuleInterop": true
},
"include": ["src"],
"exclude": ["node_modules", "lib"]
}