@@ -146,7 +146,7 @@ function getJsxEmit(typescript: typeof ts, jsx: string) {
146
146
return map [ jsx . toLowerCase ( ) ] ;
147
147
}
148
148
149
- function getCompilerOptions ( settings : compile . Settings ) : ts . CompilerOptions {
149
+ function getCompilerOptions ( settings : compile . Settings , projectPath : string ) : ts . CompilerOptions {
150
150
const tsSettings : ts . CompilerOptions = { } ;
151
151
152
152
var typescript = settings . typescript || ts ;
@@ -218,6 +218,15 @@ function getCompilerOptions(settings: compile.Settings): ts.CompilerOptions {
218
218
// Suppress errors when providing `allowJs` without `outDir`.
219
219
( < tsApi . TSOptions18 > tsSettings ) . suppressOutputPathCheck = true ;
220
220
221
+ if ( ( < tsApi . TSOptions20 > tsSettings ) . baseUrl ) {
222
+ ( < tsApi . TSOptions20 > tsSettings ) . baseUrl = path . resolve ( projectPath , ( < tsApi . TSOptions20 > tsSettings ) . baseUrl ) ;
223
+ }
224
+ if ( ( < tsApi . TSOptions20 > tsSettings ) . rootDirs ) {
225
+ ( < tsApi . TSOptions20 > tsSettings ) . rootDirs = ( < tsApi . TSOptions20 > tsSettings ) . rootDirs . map (
226
+ dir => path . resolve ( projectPath , dir )
227
+ ) ;
228
+ }
229
+
221
230
return tsSettings ;
222
231
}
223
232
@@ -272,9 +281,11 @@ module compile {
272
281
export function createProject ( fileNameOrSettings ?: string | Settings , settings ?: Settings ) : Project {
273
282
let tsConfigFileName : string = undefined ;
274
283
let tsConfigContent : tsConfig . TsConfig = undefined ;
284
+ let projectDirectory = process . cwd ( ) ;
275
285
if ( fileNameOrSettings !== undefined ) {
276
286
if ( typeof fileNameOrSettings === 'string' ) {
277
287
tsConfigFileName = fileNameOrSettings ;
288
+ projectDirectory = path . dirname ( fileNameOrSettings ) ;
278
289
// load file and strip BOM, since JSON.parse fails to parse if there's a BOM present
279
290
let tsConfigText = fs . readFileSync ( fileNameOrSettings ) . toString ( ) ;
280
291
const typescript = ( settings && settings . typescript ) || ts ;
@@ -300,7 +311,7 @@ module compile {
300
311
}
301
312
}
302
313
303
- const project = new Project ( tsConfigFileName , tsConfigContent , getCompilerOptions ( settings ) , settings . noExternalResolve ? true : false , settings . sortOutput ? true : false , settings . typescript ) ;
314
+ const project = new Project ( tsConfigFileName , tsConfigContent , getCompilerOptions ( settings , projectDirectory ) , settings . noExternalResolve ? true : false , settings . sortOutput ? true : false , settings . typescript ) ;
304
315
305
316
// Isolated modules are only supported when using TS1.5+
306
317
if ( project . options [ 'isolatedModules' ] && ! tsApi . isTS14 ( project . typescript ) ) {
0 commit comments