diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c2c10ed96..55553561b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.44.1](https://github.com/aws/jsii/compare/v1.44.0...v1.44.1) (2021-11-16) + +* revert "fix: dependency submodules may not be discovered" ([#3170](https://github.com/aws/jsii/pull/3170)) ([0449dd9](https://github.com/aws/jsii/commit/0449dd92ce3297b065c171efafc28d1f877432cc)) + ## [1.44.0](https://github.com/aws/jsii/compare/v1.43.0...v1.44.0) (2021-11-15) diff --git a/lerna.json b/lerna.json index 7feca2c485..56890a91fe 100644 --- a/lerna.json +++ b/lerna.json @@ -3,13 +3,12 @@ "npmClient": "yarn", "useWorkspaces": true, "packages": [ - "packages/*", - "regression-tests/@*/*" + "packages/*" ], "command": { "bootstrap": { "rejectCycles": true } }, - "version": "1.44.0" + "version": "1.44.1" } diff --git a/package.json b/package.json index a663eca198..90690b0f36 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ "packages/*", "packages/@jsii/*", "packages/@scope/*", - "regression-tests/@*/*", "tools/*" ], "nohoist": [ diff --git a/packages/jsii/lib/assembler.ts b/packages/jsii/lib/assembler.ts index c3c0de3c53..675653ad4e 100644 --- a/packages/jsii/lib/assembler.ts +++ b/packages/jsii/lib/assembler.ts @@ -3213,13 +3213,7 @@ function inferRootDir(program: ts.Program): string | undefined { .map((fileName) => path.relative(program.getCurrentDirectory(), path.dirname(fileName)), ) - .map(segmentPath) - // Dependency entry points are in this path, and they MAY resolve from the - // same mono-repo, in which case they won't appear to be external libraries, - // as there may not be a `/node_modules/` segment in their canonical path. - // They well however come from a parent directory, so their path segments - // will start with "..". - .filter(([head]) => head !== '..'); + .map(segmentPath); const maxPrefix = Math.min( ...directories.map((segments) => segments.length - 1), diff --git a/packages/jsii/lib/compiler.ts b/packages/jsii/lib/compiler.ts index 7f443f3ee9..aaae7f1799 100644 --- a/packages/jsii/lib/compiler.ts +++ b/packages/jsii/lib/compiler.ts @@ -133,15 +133,11 @@ export class Compiler implements Emitter { const pi = this.options.projectInfo; const projectRoot = pi.projectRoot; const host = ts.createWatchCompilerHost( - this.rootFiles, + this.configPath, { ...pi.tsc, ...BASE_COMPILER_OPTIONS, noEmitOnError: false, - tsBuildInfoFile: path.join( - pi.tsc?.outDir ?? pi.tsc?.rootDir ?? pi.projectRoot, - 'tsconfig.tsbuildinfo', - ), }, { ...ts.sys, @@ -152,7 +148,6 @@ export class Compiler implements Emitter { ts.createEmitAndSemanticDiagnosticsBuilderProgram, opts?.reportDiagnostics, opts?.reportWatchStatus, - this.typescriptConfig?.references, ); if (!host.getDefaultLibLocation) { throw new Error( @@ -500,47 +495,23 @@ export class Compiler implements Emitter { * This makes it so that running 'tsc' and running 'jsii' has the same behavior. */ private determineSources(files: string[]): string[] { - const ret = new Set(); + const ret = new Array(); if (files.length > 0) { - for (const file of files) { - ret.add(path.resolve(this.options.projectInfo.projectRoot, file)); - } + ret.push(...files); } else { const parseConfigHost = parseConfigHostFromCompilerHost( this.compilerHost, ); - // Note: the fileNames here are resolved by the parseConfigHost. - const { fileNames } = ts.parseJsonConfigFileContent( + const parsed = ts.parseJsonConfigFileContent( this.typescriptConfig, parseConfigHost, this.options.projectInfo.projectRoot, ); - for (const file of fileNames) { - ret.add(file); - } + ret.push(...parsed.fileNames); } - // Bonus: ensure all dependencies' entry points are included in the compiler - // input path. This guarantees we have symbols for all types, from the - // module root, which is necessary in order to properly detect submodules. - for (const assm of this.options.projectInfo.dependencyClosure) { - const { resolvedModule } = ts.resolveModuleName( - assm.name, - path.join( - this.options.projectInfo.projectRoot, - this.options.projectInfo.types, - ), - this.typescriptConfig?.compilerOptions ?? {}, - ts.sys, - ); - if (!resolvedModule) { - continue; - } - ret.add(resolvedModule.resolvedFileName); - } - - return Array.from(ret); + return ret; } /** diff --git a/regression-tests/@barrelimports/consumer/.gitignore b/regression-tests/@barrelimports/consumer/.gitignore deleted file mode 100644 index 0c4e0081d6..0000000000 --- a/regression-tests/@barrelimports/consumer/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/.jsii -/tsconfig.json -*.js -*.d.ts diff --git a/regression-tests/@barrelimports/consumer/README.md b/regression-tests/@barrelimports/consumer/README.md deleted file mode 100644 index eaf22f65b1..0000000000 --- a/regression-tests/@barrelimports/consumer/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# @barrelimport/consumer - -This library re-exports a type imported from a barrel location within -`@barrelimport/provider`, without actually importing `@barrelimport/provider` -itself, so we validate the jsii compiler correctly identifies the submodule -declarations. diff --git a/regression-tests/@barrelimports/consumer/lib/index.ts b/regression-tests/@barrelimports/consumer/lib/index.ts deleted file mode 100644 index d5ced1d6bf..0000000000 --- a/regression-tests/@barrelimports/consumer/lib/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Directly importing NamespacedStruct, NEVER having imported @barrelimports/provider -import { NamespacedStruct } from '@barrelimports/provider/lib/namespaced'; - -export class UsingBarrelImport { - public constructor(public readonly props: NamespacedStruct) { } -} diff --git a/regression-tests/@barrelimports/consumer/package.json b/regression-tests/@barrelimports/consumer/package.json deleted file mode 100644 index 716fbdfd2d..0000000000 --- a/regression-tests/@barrelimports/consumer/package.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "@barrelimports/consumer", - "version": "0.0.0", - "private": true, - "license": "Apache-2.0", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "author": { - "name": "Amazon Web Services", - "url": "https://aws.amazon.com" - }, - "repository": { - "type": "git", - "url": "https://github.com/aws/jsii.git", - "directory": "regression-tests/@barrelimports/provider" - }, - "scripts": { - "build": "jsii" - }, - "peerDependencies": { - "@barrelimports/provider": "0.0.0" - }, - "devDependencies": { - "@barrelimports/provider": "0.0.0", - "jsii": "^0.0.0" - }, - "jsii": { - "targets": {} - } -} diff --git a/regression-tests/@barrelimports/provider/.gitignore b/regression-tests/@barrelimports/provider/.gitignore deleted file mode 100644 index 0c4e0081d6..0000000000 --- a/regression-tests/@barrelimports/provider/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/.jsii -/tsconfig.json -*.js -*.d.ts diff --git a/regression-tests/@barrelimports/provider/README.md b/regression-tests/@barrelimports/provider/README.md deleted file mode 100644 index 32226a5f72..0000000000 --- a/regression-tests/@barrelimports/provider/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# @barrelimport/provider - -This library provides a single namespaced export struct, so that we can validate -the jsii compiler is correctly able to identify submodule declarations when the -package entry point is never imported by the consuming code. diff --git a/regression-tests/@barrelimports/provider/lib/index.ts b/regression-tests/@barrelimports/provider/lib/index.ts deleted file mode 100644 index be34190b86..0000000000 --- a/regression-tests/@barrelimports/provider/lib/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * as namespaced from './namespaced'; diff --git a/regression-tests/@barrelimports/provider/lib/namespaced.ts b/regression-tests/@barrelimports/provider/lib/namespaced.ts deleted file mode 100644 index b64a2a52d0..0000000000 --- a/regression-tests/@barrelimports/provider/lib/namespaced.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface NamespacedStruct { - readonly name: string; -} diff --git a/regression-tests/@barrelimports/provider/package.json b/regression-tests/@barrelimports/provider/package.json deleted file mode 100644 index 58733bc50a..0000000000 --- a/regression-tests/@barrelimports/provider/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@barrelimports/provider", - "version": "0.0.0", - "private": true, - "license": "Apache-2.0", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "author": { - "name": "Amazon Web Services", - "url": "https://aws.amazon.com" - }, - "repository": { - "type": "git", - "url": "https://github.com/aws/jsii.git", - "directory": "regression-tests/@barrelimports/provider" - }, - "scripts": { - "build": "jsii" - }, - "devDependencies": { - "jsii": "^0.0.0" - }, - "jsii": { - "targets": {} - } -} diff --git a/regression-tests/README.md b/regression-tests/README.md deleted file mode 100644 index 8dd92a9763..0000000000 --- a/regression-tests/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Regression Tests - -This directory contains packages that are supposed to cleanly compile using -`jsii`. This validates the compiler is able to correctly interpret the source. - -When adding new tests, be sure to follow these guidelines: - -- Create a new namespace for each regression scenario -- All packages should have `private: true` in their `package.json` -- Provide a README.md with an explanation of what the package(s) validate