Skip to content

Commit 0bddebd

Browse files
author
mariaaenc
committed
chore: add paths mapper to tsconfig
1 parent 2cea24f commit 0bddebd

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

jest.config.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,17 @@ module.exports = {
33
collectCoverage: false,
44
preset: 'ts-jest',
55
testEnvironment: 'node',
6-
}
6+
moduleNameMapper: {
7+
'^@common/(.*)$': '<rootDir>/src/common/$1',
8+
'^@controllers/(.*)$': '<rootDir>/src/controllers/$1',
9+
'^@middlewares/(.*)$': '<rootDir>/src/middlewares/$1',
10+
'^@models/(.*)$': '<rootDir>/src/models/$1',
11+
'^@routes/(.*)$': '<rootDir>/src/routes/$1',
12+
'^@services/(.*)$': '<rootDir>/src/services/$1',
13+
},
14+
globals: {
15+
'ts-jest': {
16+
tsconfig: 'tsconfig.json',
17+
},
18+
},
19+
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"author": "Marcelo 'Mark' Kopmann",
66
"scripts": {
77
"dev": "concurrently \"nodemon\" \"nodemon -x tsoa spec\"",
8-
"build": "tsoa spec && tsc && cp src/swagger.json dist/swagger.json",
8+
"build": "tsoa spec && tsc -p tsconfig.build.json && cp src/swagger.json dist/swagger.json",
99
"start": "node dist/index.js",
1010
"test": "jest test",
1111
"doc": "tsoa spec",

tsconfig.build.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"exclude": [
4+
"src/**/*.test.ts"
5+
]
6+
}

tsconfig.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77
"allowSyntheticDefaultImports": true,
88
"outDir": "dist",
99
"rootDir": "src",
10+
"baseUrl": "./src",
1011
"experimentalDecorators": true,
11-
},
12-
"exclude": [
13-
"test"
14-
]
15-
}
12+
"paths": {
13+
"@common/*": ["common/*"],
14+
"@controllers/*": ["controllers/*"],
15+
"@middlewares/*": ["middlewares/*"],
16+
"@models/*": ["models/*"],
17+
"@routes/*": ["routes/*"],
18+
"@services/*": ["services/*"]
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)