Skip to content

Commit

Permalink
feat(jsii): allow specifying baseUrl and paths in tsconfig.json (#3662)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RomainMuller committed Jul 18, 2022
1 parent f1ac393 commit 7eb11b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ are set in the `jsii.tsc` section of the `package.json` file, but use the same n
default, all visible `@types/*` packages will be loaded, which can be undesirable (in particular in monorepos, where
some type libraries are not compatible with the TypeScript compiler version that `jsii` uses). The value specified
here will be forwarded as-is to the TypeScript compiler.
- `baseUrl` and `paths` can be used to configure TypeScript path mappings, and are copied verbatim to `tsconfig.json`.

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

Expand Down
5 changes: 5 additions & 0 deletions packages/jsii/lib/project-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export type TSCompilerOptions = Partial<
// Directory preferences
| 'outDir'
| 'rootDir'
// TypeScript path mapping
| 'baseUrl'
| 'paths'
// Style preferences
| 'forceConsistentCasingInFileNames'
// Source map preferences
Expand Down Expand Up @@ -220,6 +223,8 @@ export function loadProjectInfo(projectRoot: string): ProjectInfoResult {
tsc: {
outDir: pkg.jsii?.tsc?.outDir,
rootDir: pkg.jsii?.tsc?.rootDir,
baseUrl: pkg.jsii?.tsc?.baseUrl,
paths: pkg.jsii?.tsc?.paths,
forceConsistentCasingInFileNames:
pkg.jsii?.tsc?.forceConsistentCasingInFileNames,
..._sourceMapPreferences(pkg.jsii?.tsc),
Expand Down

0 comments on commit 7eb11b7

Please sign in to comment.