From ecffb9f9dd7f02643fb2af30d9c0052f7465691d Mon Sep 17 00:00:00 2001 From: Romain Marcadier Date: Mon, 15 Feb 2021 18:20:29 +0100 Subject: [PATCH] fix(jsii): excessive "exclude" in "tsconfig.json" (#1736) In cases where both `jsii.tsc.outDir` and `jsii.tsc.rootDir` are set, and `rootDir` happens to be a parent directory of `outDir`, the generated `exclude` would match all files from `rootDir`, resulting in an empty input set. This makes sure to not emit an `exclude` declaration for `outDir` in this case, so that input files do not get excluded. --- 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 --- packages/@scope/jsii-calc-base-of-base/package.json | 8 ++++++-- packages/jsii/lib/compiler.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/@scope/jsii-calc-base-of-base/package.json b/packages/@scope/jsii-calc-base-of-base/package.json index 8ae47f6a39..97e59d1550 100644 --- a/packages/@scope/jsii-calc-base-of-base/package.json +++ b/packages/@scope/jsii-calc-base-of-base/package.json @@ -21,8 +21,8 @@ "engines": { "node": ">= 10.3.0" }, - "main": "lib/index.js", - "types": "lib/index.d.ts", + "main": "build/lib/index.js", + "types": "build/lib/index.d.ts", "scripts": { "build": "jsii --project-references && jsii-rosetta", "pacmak": "jsii-pacmak", @@ -58,6 +58,10 @@ "module": "scope.jsii_calc_base_of_base" } }, + "tsc": { + "outDir": "./build", + "rootDir": "." + }, "versionFormat": "short", "metadata": { "jsii": { diff --git a/packages/jsii/lib/compiler.ts b/packages/jsii/lib/compiler.ts index 0aa0c96bef..49b1162927 100644 --- a/packages/jsii/lib/compiler.ts +++ b/packages/jsii/lib/compiler.ts @@ -318,8 +318,12 @@ export class Compiler implements Emitter { ], exclude: [ 'node_modules', - ...pi.excludeTypescript, - ...(pi.tsc?.outDir != null + ...(pi.excludeTypescript ?? []), + ...(pi.tsc?.outDir != null && + (pi.tsc?.rootDir == null || + path + .resolve(pi.tsc.outDir) + .startsWith(path.resolve(pi.tsc.rootDir) + path.sep)) ? [path.join(pi.tsc.outDir, '**', '*.ts')] : []), ],