Skip to content

Commit 7eb11b7

Browse files
authored
feat(jsii): allow specifying baseUrl and paths in tsconfig.json (#3662)
Allow user control of the `baseUrl` and `paths` compiler options in `tsconfig.json` via the `jsii.tsc` stanza in `package.json`. Fixes #865 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
1 parent f1ac393 commit 7eb11b7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Diff for: gh-pages/content/user-guides/lib-author/configuration/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ are set in the `jsii.tsc` section of the `package.json` file, but use the same n
197197
default, all visible `@types/*` packages will be loaded, which can be undesirable (in particular in monorepos, where
198198
some type libraries are not compatible with the TypeScript compiler version that `jsii` uses). The value specified
199199
here will be forwarded as-is to the TypeScript compiler.
200+
- `baseUrl` and `paths` can be used to configure TypeScript path mappings, and are copied verbatim to `tsconfig.json`.
200201

201202
Refer to the [TypeScript compiler options reference][ts-options] for more information about those options.
202203

Diff for: packages/jsii/lib/project-info.ts

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export type TSCompilerOptions = Partial<
2020
// Directory preferences
2121
| 'outDir'
2222
| 'rootDir'
23+
// TypeScript path mapping
24+
| 'baseUrl'
25+
| 'paths'
2326
// Style preferences
2427
| 'forceConsistentCasingInFileNames'
2528
// Source map preferences
@@ -220,6 +223,8 @@ export function loadProjectInfo(projectRoot: string): ProjectInfoResult {
220223
tsc: {
221224
outDir: pkg.jsii?.tsc?.outDir,
222225
rootDir: pkg.jsii?.tsc?.rootDir,
226+
baseUrl: pkg.jsii?.tsc?.baseUrl,
227+
paths: pkg.jsii?.tsc?.paths,
223228
forceConsistentCasingInFileNames:
224229
pkg.jsii?.tsc?.forceConsistentCasingInFileNames,
225230
..._sourceMapPreferences(pkg.jsii?.tsc),

0 commit comments

Comments
 (0)